Nginx not relaying web memory update response back to client?

I am using Nginx + Websockets in exact 64 vagrant box, with C # / mono for an application server. The goal is to serve static content directly through Nginx and handle both simple HTTP service requests (on / service) and websocket requests (on / webSocket) on the same port. Here's the relevant conf:

map $http_upgrade $connection_upgrade {
    default upgrade;
    ''      close;
}

server {
    listen              80  default_server;

    # (1)
    location / {
        root            /var/www;
        index           index.html;
    }

    # (2)
    location /service {
        add_header      Access-Control-Allow-Origin *;
        proxy_pass      http://localhost:9000;
    }

    # (3)
    location /webSocket {
        proxy_pass         http://localhost:9000;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection $connection_upgrade;
    }
}

      

Most of the work works well. Static content, yes, service requests, and even the first part of websites. I am getting a well-formed 101 Switching Protocols request from my client (Firefox or Chrome). I am making a nice HTTP update response and posting it. And then the client does ... nothing ... nothing is received.

But the crazy thing is when I give up and manually kill the server side application and the client websocket closes with an error, THEN the response headers show up in the client browser debugger. Everything looks like this:

REQUEST HEADERS
Request URL:    http://localhost:8086/webSocket
Request Method:     GET
Status Code:    HTTP/1.1 101 Switching Protocols
Request Headers 16:18:50.000
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0)    Gecko/20100101  Firefox/38.0
Upgrade:    websocket
Sec-WebSocket-Version:  13
Sec-WebSocket-Key:  Nx0sUAemOFWM2rsaCAJpfQ==
Sec-WebSocket-Extensions:   permessage-deflate
Pragma: no-cache
Origin: http://localhost:8086
Host:   localhost:8086
Connection: keep-alive, Upgrade
Cache-Control:  no-cache
Accept-Language:    en-US,en;q=0.5
Accept-Encoding:    gzip, deflate
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8

RESPONSE HEADERS Δ19660ms
Upgrade:    websocket
Transfer-Encoding:  chunked
Server: nginx/1.1.19
Sec-WebSocket-Accept:   gNiAeqxcVjkiReIpdtP0EZiClpg=
Date:   Mon, 08 Jun 2015 20:18:48 GMT
Connection: keep-alive

NO RESPONSE BODY Δ0ms

      

There is no evidence that my server application is not deleting the send data right away - I use async TcpSocket.BeginSend and FinishSend and the send seems to be complete right away. And it works great on a regular mail service.

So where are my websocket posts ???? It seems that Nginx doesn't want to send it back to my client, except when I close the Tcp connection from the server side.

Has anyone experienced this before. Everything I've read on Nginx and Websockets has to do with a basic setup where hop-by-hop update works, and I have it. No one can tell why sending from the server seems to go nowhere.

+3


source to share





All Articles