What version of ejabberd are you using?
Ejabberd 18.06
What operating system (version) are you using?
Ubuntu 16.04
How did you install ejabberd (source, package, distribution)?
Source
What did not work as expected? Are there error messages in the log?
When ejabberd is accessed through websocket directly ws://chat.test:5280/ws (Using Stropje.js) I'm able to connect to the server
However, if I use http://chat.test/ws I'm getting 400 Bad Request
Here's my NGINX config - Where chat.test is a virtual host
location /ws {
proxy_pass http://127.0.0.1:5280/ws;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Appreciate any pointers please.
Thanks
Seeing the same with Conversejs, works with the included http_fileserver though.
Update:
proxy_http_version 1.1;location /ws {
proxy_pass http://127.0.0.1:5280/ws;
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
ws://chat.test:5280/ws using Strophe - This is what I see in the log file 2018-12-24 01:10:31.618 [debug] <0.16549.0>@ejabberd_http:init:147 S: [{[<<"ws">>],ejabberd_http_ws},{[<<"bosh">>],mod_bosh},{[<<"api">>],mod_http_api},{[<<"admin">>],ejabberd_web_admin},{[<<"http-bind">>],mod_bosh}]
2018-12-24 01:10:31.618 [debug] <0.16549.0>@ejabberd_http:process_header:305 (#Port<0.19959>) http query: 'GET' <<"/ws">>
2018-12-24 01:10:31.619 [debug] <0.16549.0>@ejabberd_http:process:392 [<<"ws">>] matches [<<"ws">>]
2018-12-24 01:10:31.619 [debug] <0.16550.0>@ejabberd_http_ws:init:146 Client connected through websocket {http_ws,<0.16550.0>,{{0,0,0,0,0,65535,2790,43534},54222}}
I see the request coming in as a GET request
However while using nginx proxy http://chat.test/ws
2018-12-24 01:11:05.622 [debug] <0.16554.0>@ejabberd_http:init:147 S: [{[<<"ws">>],ejabberd_http_ws},{[<<"bosh">>],mod_bosh},{[<<"api">>],mod_http_api},{[<<"admin">>],ejabberd_web_admin},{[<<"http-bind">>],mod_bosh}]
2018-12-24 01:11:05.622 [debug] <0.16554.0>@ejabberd_http:process_header:305 (#Port<0.19961>) http query: 'POST' <<"/ws">>
2018-12-24 01:11:05.623 [debug] <0.16554.0>@ejabberd_http:process:392 [<<"ws">>] matches [<<"ws">>]
I see the request coming in as a POST request
What could be causing this?
Appreciate any pointers please.
Hello,
I am guessing that this will be fixed if you use ws://chat.test/ws url (strophe will use bosh protocol for http:// urls, and thats not compatible with websocket connection).
Thanks @prefiks
Adding this line to establish the connection indeed solved the issue!
Chat.connection = new Strophe.Connection("ws://chat.test/ws/");
Thank you!
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
Hello,
I am guessing that this will be fixed if you use ws://chat.test/ws url (strophe will use bosh protocol for http:// urls, and thats not compatible with websocket connection).