SteeltoeOSS / Connectors

Connectors simplify connecting to standalone and CloudFoundry services
https://steeltoe.io/docs/steeltoe-connectors/
Apache License 2.0
27 stars 13 forks source link

Redis connector doesn't use hostnames on Mac or Linux #4

Closed autodidaddict closed 6 years ago

autodidaddict commented 7 years ago
Error Message:
 System.Exception : Could not resolve a service of type '(my class)' for the parameter 'eventProcessor' of method 'Configure' on type '(my startup)'.
---- System.AggregateException : One or more errors occurred. (**This platform does not support connecting sockets to DNS endpoints via the instance Connect and ConnectAsync methods, due to the potential for a host name to map to multiple IP addresses and sockets becoming invalid for use after a failed connect attempt. Use the static ConnectAsync method, or provide to the instance methods the specific IPAddress desired.**)
-------- System.PlatformNotSupportedException : This platform does not support connecting sockets to DNS endpoints via the instance Connect and ConnectAsync methods, due to the potential for a host name to map to multiple IP addresses and sockets becoming invalid for use after a failed connect attempt. Use the static ConnectAsync method, or provide to the instance methods the specific IPAddress desired.

This error comes up when you provide a hostname like localhost or a fully-qualified hostname pointing at a cloud-based installation of redis (for example, the one you get when you use Pivotal Web Services hosting). In other words, if my service binding gives me an IP address, then I'm fine on Linux/Mac, but if my service binding gives me a host name, then I'm screwed and when I take my windows-running app from my developer workstation and push it to my linux cell in PCF, then I'm in for an ugly surprise when I try and start the app.

dtillman commented 7 years ago

Kevin, Ya... this is a known problem in .NET Core.. and the Stackexchange guys are struggling with ... https://github.com/StackExchange/StackExchange.Redis/issues/410 ...

Let me check the latest on this and see if it got fixed in .NET Core or a work around was put in place by the stackexchange guys.

Dave

dtillman commented 7 years ago

Looks like a work around from stack exchange is in the works .. also seems that setting "resolveDns= true" in your appsettings.json might also work around the issue. My testing on my Mac showed that if I set "host=myMacsHostName" and set "resolveDns=true" .. the the.NET Core exception goes away.

For some reason setting "host=localhost" still failed, Dave

tillig commented 7 years ago

Possibly helpful to future readers: I got the This platform does not support connecting sockets to DNS endpoints exception on a Linux cell when my Redis service broker started giving me strong passwords that have commas in them. Something to look for. #10

DreamingDevs commented 7 years ago

@dtillman Your post solved my problem. thank you.

mhoran commented 7 years ago

Adding the follwing to appsettings.json resolved this for me, using Steeltoe Connectors and Cloud Foundry:

{
  "redis": {
    "client": {
      "resolveDns": true
    }
  }
}
TimHess commented 6 years ago

This appears to be resolved