Deployment of SignalR with nginx

At the beginning of the semester, I took software engineering course which has a term project. It requires us to do real-time web application. After discussion with team members, we chose ASP.NET Core with SignalR. While I was writing this story, SignalR is on alpha stage (1.0.0-alpha2). Therefore, it has issues. Such as, the documentation is incomplete, some of the features are under development and there is no information about unit testing or functionality testing etc. Of course, somehow you can achieve those things, no doubt, but you have to work hard. In this story, I will mention about deployment of SignalR with nginx.


Error during WebSocket handshake: Unexpected response code: 204


If you need to create a WebSocket connection from scratch, you’ll have to handle the handshaking process yourself. After creating the initial HTTP/1.1 session, you need to request the upgrade by adding to a standard request the Upgrade and Connection headers, as follows: Connection: Upgrade Upgrade: websocket

Source Mozilla

The deployment documentation sets the connection header as keep-alive. And, WebSocket does not working with keep-alive. In our project, SignalR Hub is mapped to “/api/chat”. So, we have to add a new location and set the connection header as “upgrade

This configuration solves the problem. Also, our term project github page is shown below.

Thats all, thanks !

ITU. CE. LCWaikiki