2

I can't really get my head around how websockets are configured and expected to work on the server.

In my case I have a machine (Windows 10) running IIS. On that machine I want to place my own websocket server application (WS-Server.exe), which should accept websocket connections from my client web app (WS-Client).

Doing all this on localhost without IIS involved is pretty stragihtforward - simply make WS-Server.exe listen on some specific port, for example 5004, and have WS-Client (the web app) connect to ws://127.0.0.1:5400.

But now I want to deploy it and make it reachable over the Internet, and here's where I get lost. I understand that the Websocket handshake can be made via a normal HTTP call to IIS on port 80, and the connection will then be "upgraded" to a websocket connection by IIS if IIS is properly configured.

  1. How do I properly configure IIS to enable websockets? I tried following the steps on Microsofts website to enable Websockets in IIS, but I'm not sure if that is all that is needed? When I try to connect to 127.0.0.1:80 from WS-Client I get an error message saying Error during WebSocket handshake: Unexpected response code: 200. As I understand it, a websocket "HTTP upgrade" response should have response code 101? So it seems IIS is just serving a normal webpage instead?

  2. How do I tell IIS that I want all websocket connections to go to WS-Server.exe, which is running on the same machine? Do I need to tell IIS that I want 5004 to be used as the websocket port somehow? It seems like this step is always missing in all guides I've found, which I don't understand - what good is a websocket connection if you don't have something running on the server machine to actually send out data on it?

2
  • docs.microsoft.com/en-us/iis/get-started/whats-new-in-iis-8/… You might get some ideas from this.
    – Lex Li
    Commented Sep 1, 2022 at 7:28
  • @LexLi Unfortunately not. I have read those, but I still don't get it. Most of the instructions seem to be for Windows Server 2012, which looks different and has different features from Windows 10. The linked blog post about IWebSocketContext - I have no idea what to do with? I have a Websocket server program written in Delphi - it's simply an exe, and I need to somehow make it reachable from the internet using IIS (I guess?).
    – Magnus
    Commented Sep 1, 2022 at 7:43

0

You must log in to answer this question.

Browse other questions tagged .