Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failed: Error during WebSocket handshake: Unexpected response code: 404 #513

Open
k0fi opened this issue Jan 17, 2018 · 1 comment
Open

Comments

@k0fi
Copy link

k0fi commented Jan 17, 2018

Hi,
I have prosody server with nginx set up on my localhost, which run fine together with other xmpp web clients like converse.js. But I'm banging my head to make Candy chat working, as I get this error, whatever configs that choose:

WebSocket connection to 'ws://127.0.0.1:5280/http-bind' failed: Error during WebSocket handshake: Unexpected response code: 404

Here is my config index.html:

		$(document).ready(function() {
			Candy.init('ws://127.0.0.1:5280/http-bind', {
				core: {
					debug: true,
					autojoin: true
				},
				view: { assets: '../res/' }
			});

			Candy.Core.connect('localhost');
		});

And /etc/nginx/sites-available/default :


server {
        listen 80 default_server;

location / {
        root /home/me/candy;
        index index.html;

        location /http-bind/ {
                proxy_pass https://127.0.0.1:5280/http-bind/;
                proxy_buffering off;
                tcp_nodelay on;
        }
        error_page  405 =200 $uri;
}
}

And /etc/prosody/prosody.cfg.lua:

modules_enabled = {
"roster";
"saslauth";
"tls";
"dialback";
"disco";
"version";
"uptime";
"time";
"ping",
"register";
"posix";
"bosh";
};
allow_registration = true;
daemonize = true;
consider_bosh_secure = true;
cross_domain_bosh = true;
pidfile = "/var/run/prosody/prosody.pid";
c2s_require_encryption = false;
authentication = "internal_plain"
log = {
debug = "/var/log/prosody/prosody.log";
error = "/var/log/prosody/prosody.err";

{ levels = { "error" }; to = "syslog";
};
}
VirtualHost "localhost"
enabled = true
ssl = {
key = "/etc/prosody/certs/example.com.key";
certificate = "/etc/prosody/certs/example.com.crt";
}
VirtualHost "anonymous.localhost"
   authentication = "anonymous"
Component "component.localhost"
component_secret = "supersecretpw"

Component "chat.localhost" "muc"

Browser console error log:

[Init] Debugging enabled
candy.bundle.js:202 [Connection] Connecting
libs.min.js:2 WebSocket connection to 'ws://127.0.0.1:5280/http-bind' failed: Error during WebSocket handshake: Unexpected response code: 404
_connect @ libs.min.js:2
connect @ libs.min.js:1
a.connect @ libs.min.js:2
a.connect @ candy.bundle.js:320
(anonymous) @ candy.bundle.js:4197
dispatch @ jquery.min.js:5
v.handle @ jquery.min.js:5
candy.bundle.js:234 [Strophe][ERROR]: Websocket error [object Event]
k.debug.b.log @ candy.bundle.js:234
error @ libs.min.js:1
_onError @ libs.min.js:2
candy.bundle.js:202 [Connection] Failed (2)
candy.bundle.js:234 [Strophe][INFO]: _doDisconnect was called
candy.bundle.js:234 [Strophe][INFO]: WebSockets _doDisconnect was called
candy.bundle.js:202 [Connection] Disconnected
candy.bundle.js:234 [Strophe][ERROR]: User connection callback caused an exception: TypeError: Cannot read property 'indexOf' of null
k.debug.b.log @ candy.bundle.js:234
error @ libs.min.js:1
_changeConnectStatus @ libs.min.js:1
_doDisconnect @ libs.min.js:1
_disconnect @ libs.min.js:2
_onError @ libs.min.js:2
candy.bundle.js:234 [Strophe][INFO]: Websocket closed

This problems bugs me for sooo long. So appreciate your hints to resolve it.

Thanks

@sleeksorrow
Copy link

I stumbled upon this issue while searching for another one that's unrelated. But while I'm here I want to comment on this.

You have enabled BOSH in your prosody and the endpoint /http-bind is correct. But BOSH is not Websocket, these are two completely different things that just have the same goal in this case. You can't connect a websocket at a BOSH endpoint.

Either you enable Websocket in your prosody which will enable the endpoint /xmpp-websocket by default, or you keep your prosody configuration as-is and configure your client to use BOSH at the /http-bind endpoint.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants