kerryjiang / WebSocket4Net

A popular .NET WebSocket Client
Apache License 2.0
764 stars 273 forks source link

Not able to use a host name to connect to web socket #85

Open jphoc13 opened 7 years ago

jphoc13 commented 7 years ago

Cannot access disposed object is the error I am receiving. For some reason the socket doesn't open and so it gets garbage collected.

I am able to use the host machine IPaddress but in trying to use the hostname I am running into issues.

sIpAddress = "host.hostname.com";
                        sPort = Convert.ToInt32("11003");
                        IPHostEntry ip = Dns.GetHostEntry(sIpAddress);
                         vWebsocket= new WebSocket("ws://" + ip.HostName + ":" + sPort + "/");

Note: I am trying to use the web socket in an iOS app on Xamarin Studio. I am able to connect from the same machine I am debugging this app on. Not sure if this matters.

kerryjiang commented 7 years ago

Do you have stacktrace of this exception.

zplzk2 commented 7 years ago

I met similar issue with mono 4.6.2.7. My server is behide ELB and that seems to matter. In this case, only IP can work. Both IP and host name work when connecting to a server without ELB.

Downgrading to mono 4.4.2.11 can fix it (working with host name and ELB).

jphoc13 commented 7 years ago

I was able to connect with a hostname for iOS, but still not able to do so in Android.