Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AngularJS: chat app with socket.io over https

I am running this example chat app https://github.com/btford/angular-socket-io-im that uses socket.io/angular/node to make a basic im client.

However I run into trouble when I try to make it work over https.

No socket events are caught on the server, so no chat messages are sent to clients and users can't join rooms. I also get this error on the client in socket.io.js:

Uncaught TypeError: Cannot call method 'onClose' of null  

I've created an express https server listening on port 8000 and modified the socket definition to :

 var socket = io.connect('https://localhost:8000',{secure: true, port:8000});

both in js/services.js and in /bower_components/angular-socket-io/socket.js

Not quite sure how to go about fixing this. Thanks in advance!

like image 693
algorithmicCoder Avatar asked Sep 04 '13 03:09

algorithmicCoder


1 Answers

I have an app that does this exact same thing :) uses socket io and uses :8080 you will need to make sure your security cert is registering that both https://localhost and https://localhost:8000 and has been added to your keychain otherwise the page will load but your socket connections will fail.

like image 75
btm1 Avatar answered Oct 21 '22 14:10

btm1