tg123 / websockify-nginx-module

Embed websockify into Nginx (convert any tcp connection into websocket)
MIT License
140 stars 59 forks source link

fails to work with spice-html5 #3

Closed ReubenM closed 9 years ago

ReubenM commented 10 years ago

spice-html5 + xSpice work together to provide a web based spice client similar to how noVNC + xVNC provide a web based VNC client.

The connection does not get passed through using the module. It does however pass through when using the standalone websockify.

tg123 commented 10 years ago

please provide some error log if you can i am going to setup the xSpice and check your problem

ReubenM commented 9 years ago

The X server logs don't show anything because they never detect a connection.

Nginx logs contain stuff like this:

[debug] 24208#0: *7 websockify : found SEC_WEBSOCKET_KEY : U8mvZT8iQbY8RA9RuWvI7Q==
[error] 24208#0: *7 connect() failed (111: Connection refused) while connecting to upstream, client: 172.16.0.189, server: , request: "GET / HTTP/1.1", upstream: "websockify://127.0.0.1:5901", host: "172.16.0.189:5959"
[info] 24208#0: *7 client 172.16.0.189 closed keepalive connection
tg123 commented 9 years ago

Connection refused means your nginx is not allow to connect the upstream 127.0.0.1:5901

please telnet 127.0.0.1 5901 on the same machine to see if you can connect from nginx to upstream

ReubenM commented 9 years ago

I must have copied and pasted from he wrong location in the logs. I removed all logs and ran it again to make sure I have the right content. The error should have been about timing out rather than connection refused.

Here's the complete uncut error log:

2014/07/14 10:54:02 [notice] 23486#0: using the "epoll" event method
2014/07/14 10:54:02 [notice] 23486#0: nginx/1.7.2
2014/07/14 10:54:02 [notice] 23486#0: OS: Linux 3.15.5-gentoo
2014/07/14 10:54:02 [notice] 23486#0: getrlimit(RLIMIT_NOFILE): 1024:4096
2014/07/14 10:54:02 [notice] 23487#0: start worker processes
2014/07/14 10:54:02 [notice] 23487#0: start worker process 23488
2014/07/14 10:54:10 [debug] 23488#0: *7 websockify : found SEC_WEBSOCKET_KEY : p6MPTNB7/6yGfJsH77HbGQ==
2014/07/14 10:54:11 [info] 23488#0: *5 client closed connection while waiting for request, client: 172.16.0.95, server: 0.0.0.0:8080
2014/07/14 10:54:11 [info] 23488#0: *6 client closed connection while waiting for request, client: 172.16.0.95, server: 0.0.0.0:8080
2014/07/14 10:54:26 [info] 23488#0: *1 client 172.16.0.95 closed keepalive connection
2014/07/14 10:54:26 [info] 23488#0: *3 client 172.16.0.95 closed keepalive connection
2014/07/14 10:54:26 [info] 23488#0: *4 client 172.16.0.95 closed keepalive connection
2014/07/14 10:54:26 [info] 23488#0: *2 client 172.16.0.95 closed keepalive connection
2014/07/14 10:55:11 [error] 23488#0: *7 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.16.0.95, server: , request: "GET / HTTP/1.1", upstream: "websockify://127.0.0.1:5901", host: "172.16.0.189:5959"
2014/07/14 10:55:11 [info] 23488#0: *7 client 172.16.0.95 closed keepalive connection
2014/07/14 10:55:46 [notice] 23514#0: signal process started                                                                                                                                                   
2014/07/14 10:55:46 [notice] 23487#0: signal 15 (SIGTERM) received, exiting                                                                                                                                    
2014/07/14 10:55:46 [notice] 23488#0: exiting                                                                                                                                                                  
2014/07/14 10:55:46 [notice] 23488#0: exit                                                                                                                                                                     
2014/07/14 10:55:46 [notice] 23487#0: signal 17 (SIGCHLD) received                                                                                                                                             
2014/07/14 10:55:46 [notice] 23487#0: worker process 23488 exited with code 0                                                                                                                                  
2014/07/14 10:55:46 [notice] 23487#0: exit

Also, I checked and telnet can connect to the 5901 port. Using both the LAN IP address, and localhost IP address.

ReubenM commented 9 years ago

Here's the related portion from nginx.conf

        server {
                listen 8080;
                root /var/www/spice-html5;

                location / {
                        index spice.html;
                }
        }

        server {
                listen 5959;

                location / {
                        websockify_pass 127.0.0.1:5901;
                }
        }
tg123 commented 9 years ago

ok I will check what is wrong

tg123 commented 9 years ago

confirmed

i am working on it

tg123 commented 9 years ago

please see branch issue 2

check if fix your problem

ReubenM commented 9 years ago

No longer times out, but console output from spice.js on the browser reads "Error: Unexpected protocol mismatch."

No connections are shown in the X11 logs.

Relevant portion from nginx logs:

[debug] 9773#0: *1 websockify : found SEC_WEBSOCKET_KEY : Sv+sk63UEtP+dL3wqUuviQ==
[debug] 9773#0: *1 websockify : ngx_http_websockify_process_header
[debug] 9773#0: *1 ngx_http_websockify_send_with_decode: [44]
[error] 9773#0: *1 ngx_http_websockify_send_with_decode: decode error!  while proxying upgraded connection, client: 172.16.0.95, server: , request: "GET / HTTP/1.1", upstream: "websockify://127.0.0.1:5901", host: "172.16.0.189:5959"
tg123 commented 9 years ago

done

image

lastest issue2 branch

    location / {
         websockify_pass YOUR SERVER;
         websockify_send_chunk_size 0;
    }

this branch just make spice work please allow time to merge to trunk

ReubenM commented 9 years ago

Confirmed, it works. :+1: