2

I'm using websocket-sharp as a webserver in a project. On Windows I create 2 HttpServers like this

HttpServer s1 = new HttpServer("http://[::0]:8080")     // IPv6
HttpServer s2 = new HttpServer("http://0.0.0.0:8080");  // IPv4

This works on all the machines I've tested.

But, a user reported getting this error from the first line

SocketException: An address incompatible with the requested protocol was used.

System.Net.Sockets.Socket..ctor (AddressFamily family, SocketType type, ProtocolType proto)
WebSocketSharp.Net.EndPointListener..ctor (System.Net.IPAddress address, Int32 port, Boolean secure, System.String certificateFolderPath, WebSocketSharp.Net.ServerSslConfiguration sslConfig, Boolean reuseAddress)
WebSocketSharp.Net.EndPointManager.getEndPointListener (System.Net.IPAddress address, Int32 port, Boolean secure, WebSocketSharp.Net.HttpListener listener)
WebSocketSharp.Net.EndPointManager.addPrefix (System.String uriPrefix, WebSocketSharp.Net.HttpListener listener)

Why?

We thought it must have something to do with that machine not having IPv6 but that's not the case. ipconfig on that machine reports

Wireless LAN adapter Wi-Fi 2:

Connection-specific DNS Suffix . :
Description . . . . . . . . . . . : Intel(R) Dual Band Wireless-AC 7265 #2
Physical Address. . . . . . . . . : 5C-E0-C5-D7-EA-6A
DHCP Enabled. . . . . . . . . . . : Yes
Autoconfiguration Enabled . . . . : Yes
Link-local IPv6 Address . . . . . : fe80::48f3:fe4f:7b1:5cf4%19(Preferred)
IPv4 Address. . . . . . . . . . . : 10.198.123.252(Preferred)

On top of that in trying to repo the issue on my own machines I've tried disabling IPv6 from the network properties. No error on my machine. I've also tried disabling IPv6 using these scripts from Microsoft. I've verified they turned off IPv6 as ipconfig shows no data related to IPv6 what-so-ever. I still no error on my machine.

The user mentioned that had VMware on their machine. They weren't running my app in VMware but VMware is on the machine and therefore installs network drivers.

So I installed VMware but still no error. Also install VirtualBox and still no error.

They also mentioned it works on their wired desktop but not on their wifi laptop so I went out and got a USB WiFi Adaptor and turned off wired access but still no error. Also tried another laptop and both Windows 8.1 and Windows 10 (same as user)

I saw this q&a that references the same error message but it's using a different lower level API

So my questions are

  1. Why is it failing on just one machine (vs the 100s it's not failing on)

  2. How to I detect when it's safe to execute the first line?

Community
  • 1
  • 1
gman
  • 100,619
  • 31
  • 269
  • 393
  • It may be related to the fact that the IPv6 stack is on NIC "2". This post may help you troubleshoot: http://stackoverflow.com/questions/1777629/how-to-listen-on-multiple-ip-addresses – JamieMeyer Nov 29 '16 at 04:05
  • Thanks but unfortunately that doesn't seem to be related. `[::0]` is the same as `IPAddress.Any`. Also I tried disabling IPv6 on my first NIC and I still don't get the error. – gman Nov 29 '16 at 05:30

0 Answers0