nori0428 / mod_websocket

mod_websocket for lighty ( http://www.lighttpd.net/ )
BSD 3-Clause "New" or "Revised" License
103 stars 27 forks source link

Unable to build the websocket connection #16

Closed didiao closed 12 years ago

didiao commented 12 years ago

Hello, and おつかれさまです。( ^_^ ) )

I have installed lighty and this module into my Linux, it seems pretty well. But when I use the chatting sample to make a confirmation, it doesn't work. I sniffed the HTTP stream and it return me the HTTP 400 error. I had viewed the ISSUE#3 but can't found any revelation. I didn't have good knowledge of that. Plz give me some help.

Here's what I'm using: CentOS 5.5, Ubuntu 9.10, Firefox 8.0, Chrome 10.0.648, lighttpd-1.4.28

I followed the wiki (https://github.com/nori0428/mod_websocket/wiki/for-CentOS-Users) to setup my module, and added that configuration into lighttpd.conf. And when I taking the chatting sample, I do like this: ① $ lighttpd -f /path/to/lighttpd.conf ② $ chat 9000 & ③ access chat.html

Is my operation or configuretion has something wrong? Or the websocket version doesn't fit very well?(I used IETF-{00,08}). Or something else?

どうも有難う御座います。

didiao commented 12 years ago

I used IETF-08 and it has been worked on my ubuntu. But these days when I do the same work on CentOS5.5, it still return HTTP 400 Error. I opened switch of debug, and get these debug information.

<--------------- I am error log : start--------------------------> 2011-11-22 23:22:40: (log.c.166) server started 2011-11-22 23:22:40: (server.c.961) WARNING: unknown config-key: websocket.server (ignored) 2011-11-22 23:33:48: (server.c.1512) server stopped by UID = 0 PID = 3417 2011-11-22 23:46:07: (log.c.166) server started 2011-11-23 00:14:40: (log.c.166) server started 2011-11-23 00:28:41: (server.c.1512) server stopped by UID = 0 PID = 3417 2011-11-23 00:33:40: (log.c.166) server started 2011-11-23 00:49:42: (log.c.166) server started 2011-11-23 00:54:31: (server.c.1512) server stopped by UID = 0 PID = 3417 2011-11-23 01:05:43: (log.c.166) server started 2011-11-23 01:06:47: (server.c.1512) server stopped by UID = 0 PID = 3417 2011-11-23 01:06:52: (log.c.166) server started 2011-11-23 01:16:38: (server.c.1512) server stopped by UID = 0 PID = 3417 2011-11-23 01:18:35: (log.c.166) server started 2011-11-23 01:18:46: (mod_websocket.c.424) found extension: /chat 2011-11-23 01:18:46: (mod_websocket_handshake.c.399) not found Origin header 2011-11-23 01:18:46: (mod_websocket.c.452) disconnect client: 8 2011-11-23 01:18:54: (mod_websocket.c.424) found extension: /chat 2011-11-23 01:18:54: (mod_websocket_handshake.c.399) not found Origin header 2011-11-23 01:18:54: (mod_websocket.c.452) disconnect client: 8 <--------------- I am error log : end-------------------------->

I also sniffed the HTTP connection, and get these TCP Stream. <--------------- I am tcp stream : start--------------------------> GET /chat HTTP/1.1 Upgrade: websocket Connection: Upgrade Host: 10.194.151.201 Origin: http://10.194.151.201 Sec-WebSocket-Key: 0ngnIJdt1nldjjXR0lffbA== Sec-WebSocket-Version: 13

HTTP/1.1 400 Bad Request Content-Type: text/html Content-Length: 349 Date: Tue, 22 Nov 2011 17:07:00 GMT Server: lighttpd/1.4.28 <?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

400 - Bad Request

400 - Bad Request

<--------------- I am tcp stream : end--------------------------> Why and how to deal with it? Thank you.

nori0428 commented 12 years ago

Thank you for comment.

The WebSocket Protocol has been changed Origin Header at version 12. And as described in your comment, Chrome beta, dev and Firefox(?) use version 13.

I'll fix this issue shortly with other issues.

But if you need to fix this immediately, please apply the following patch.

--- ./mod_websocket_handshake.c.old 2011-11-22 19:45:47.043015353 +0900 +++ mod_websocket_handshake.c 2011-11-18 18:27:25.497721906 +0900 @@ -37,10 +37,10 @@

define SEC_WEBSOCKET_PROTOCOL_STR "Sec-WebSocket-Protocol"

define SEC_WEBSOCKET_ORIGIN_STR "Sec-WebSocket-Origin"

+#define ORIGIN_STR "Origin"

ifdef _MOD_WEBSOCKET_SPEC_IETF00

define WEBSOCKET_STR "WebSocket"

-# define ORIGIN_STR "Origin"

define SEC_WEBSOCKET_LOCATION_STR "Sec-WebSocket-Location"

define SEC_WEBSOCKET_KEY1_STR "Sec-WebSocket-Key1"

define SEC_WEBSOCKET_KEY2_STR "Sec-WebSocket-Key2"

@@ -356,7 +356,9 @@

ifdef _MOD_WEBSOCKET_SPEC_IETF08

     if (buffer_is_equal_string(hdr->key,
nori0428 commented 12 years ago

Ah sorry. Spaces for indent are deleted... Fix it as soon as possible, please wait.

Thanks.

nori0428 commented 12 years ago

added for RFC-6455 spec. solved