mkuklis / phonegap-websocket

Websocket PhoneGap plugin for Android
203 stars 78 forks source link

Socket.IO With 'authorization' #40

Open alanjames1987 opened 10 years ago

alanjames1987 commented 10 years ago

In order to have Socket.IO and Express share the same session data a sessionStore and cookie have to be used. This works great on browers, but PhoneGap is giving me problems.

I referenced your Socket.IO example and the socket.on('error'... event keeps firing. I looked at my Socket.IO log and this is the error I am getting when PhoneGap tries to connect.

GET /socket.io/1/?t=1396314433839 302 2ms - 82b
   debug - authorized
   warn  - handshake error MISSING_COOKIE

I'm using PhoneGap 3.4.0 on Android 4.2.2 on a Galaxy Nexus.

Do you know how I can fix this?

mkuklis commented 10 years ago

@alanjames1987 that's strange. I'm using a similar setup here (cookie based auth with express) and things are working fine for me. What version of socket.io-client do you use? Do things work fine for you when testing from the browser?

alanjames1987 commented 10 years ago

I've been using 0.9.6 as the client and server. I've been using socket.io-session to connect my Express and Socket.IO sessions.

From what I can see it looks like PhoneGap just never works with cookies. I might be wrong on this but it looks like I will have to write my own authorization function to handle different requests from browsers or PhoneGap.

This should be no problem, but it's just a drag that PhoneGap didn't behave exactly like browsers do.

eldyvoon commented 7 years ago

I'm having the same issue http://stackoverflow.com/questions/38550654/socket-io-auth-doesnt-work-on-cordova-mobile

mkuklis commented 7 years ago

@eldyvoon I would suggest switching from a cookie based auth to a token based.