ServiceStack.Redis: Unable to Connect: sPort: 0

2020-03-19 03:34发布

Sometimes (not always) I am getting

"Unable to Connect: sPort: 0"

error when trying to get value from Redis when using ServiceStack.Redis. Does anyone know what that might mean? I am using PooledRedisClientManager to get the client.

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2020-03-19 04:02

It might mean that the port number or host address is wrong.

查看更多
家丑人穷心不美
3楼-- · 2020-03-19 04:07

I believe you can fix this by increasing the pool's ConnectTimeout. I had it set very low (10ms), so when the pool was created, some of the clients were unable to connect in that short period. If the pool returned one of these clients, it would throw this error (the "0" port is because it's not connected -- it doesn't know what port it's not connected to). After a delay, all of the clients are able to connect.

I increased my connect timeout to 500ms, and the problem went away -- the clients all connect, though some of them block for a couple hundred milliseconds. But that's much better than an error.

查看更多
登录 后发表回答