2

I'm developing a site using WebSockets and I'm using XSockets.NET to implement the whole WebSockets server.

Furthermore, I'm able to reach XSocket.NET controller from within the development machine, but I'm unable to reach it from another machine.

BTW, it's not a DNS problem because the Web site itself is browsable from any other machine: it's something with WebSockets.

Currently I'm receiving the following error in Firebug: Firefox can't establish a connection to the server [...], where the server is the whole hostname on port 7532.

I can provide a sample code of how I'm configuring and starting the whole WebSockets server:

IXSocketServerContainer server = Composable.GetExport<IXSocketServerContainer>();
List<IConfigurationSetting> serverConfig = new List<IConfigurationSetting>();
serverConfig.Add(new ConfigurationSetting("ws://[host name]:7532", new HashSet<string> { "*" }));
server.StartServers(configurationSettings: serverConfig);

Also, the whole XSockets.NET is hosted in a Windows Service, and I'm connecting to the XSocket.NET controller using the out-of-the-box XSockets.NET JavaScript API:

// This will work as expected when I open my site from the development machine
var conn = new XSockets.WebSocket("ws://[host name]:7352/[controller name]");

conn.on(XSockets.Events.open, function (clientInfo) {
    conn.subscribe("[Action name]", function (message) {
    });
});

What would prevent other machines from connecting to the whole WebSocket server? What am I missing?

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206

2 Answers2

2

I've solved it, and it's a minimum change.

It seems that XSockets.NET requires to configure the WebSocket to listen any IP and any host. That is, the whole host should be 0.0.0.0:7532.

Surprisingly, I've found the solution in a comment on this XSockets.NET documentation page (Creating custom configuration ...):

VJ: Ok. So I have an update to the problem I mentioned above. A possible solution, which it is for me anyway.

  1. In the CustomConfigLoader, I am going to add the ip address as 0.0.0.0, which means my XSockets server will listen from any ip address. Therefore, the code would look like this: var url="ws://0.0.0.0:4502/";

  2. In the Javascript I will use window.location.hostname, which points to the host of the application, essentially the server as know to the client, I am using my XSockets with.

Second step was already how I did in my code, and first was what made the trick (in my case, I've not used a CustomConfigLoader, but I just added a ConfigurationSetting with 0.0.0.0:7352 as host IP/hostname).

Matías Fidemraizer
  • 63,804
  • 18
  • 124
  • 206
1

Can you actually see that port open from outside if you run a TCP scan?

Have you tried to use a wss:// (secure) connection? Your service or hosting provider may have a transparent proxy that is not websocket friendly. Going secure avoids problems with proxies in the way.

There is no documentation for SSL/TLS in the latest version of XSocket.net, but probably it is very similar to the older version.

vtortola
  • 34,709
  • 29
  • 161
  • 263
  • I believe you guessed a lot! I'm not hosting it in an external company. The development machine is a VM, and it works there, and if I try to access the site from the host machine or, for example, my tablet, the whole WebSocket isn't reachable. I've tried a `telnet [host] [port]` but it doesn't work both in the VM and external machine. – Matías Fidemraizer Jun 25 '14 at 06:43
  • Also, I've disabled Windows Firewall both in VM and host machine. – Matías Fidemraizer Jun 25 '14 at 06:54