[SOLVED] Socket.io, can't connect on iOS 10


Anyone using socket.io-client ? Do you face any problem on iOS 10?

For me everything work like on charm on Android and iOS <= 9. On iOS 10 I can’t establish a connection. Do I make something wrong or do I miss something?

 this.socket = io.connect(Resources.Constants.API.SERVER_DOMAIN, {
    'transports': ['websocket', 'xhr-polling'],
    'query': 'token=' + myToken

alert('test:' + this.socket.id); // undefined
 alert('test:' + this.socket.connected); // false

Any help would be much appreciated!


It turns out that last Safari is more picky about CSP than the others.

Adding ws://* wss://* to my connect-src in my Content-Security-Policy solved my issue.

 <meta http-equiv="Content-Security-Policy" content="default-src data: gap://* file://* https://ssl.gstatic.com *; img-src 'self' * data:; style-src 'self' 'unsafe-inline' *; script-src 'self' 'unsafe-eval' 'unsafe-inline' *; connect-src 'self' * ws://* wss://*;">


i am getting the same issue. working fine in web. but not in iPhone.

I install it as an app. added the Content-Security-Policy into index.html doesn’t help .

any other ideas?


For me I found the solution while testing it in Safari instead as Chrome as I mostly do…does it work for you when you debug locally in Safari?


working good in browser. but not the app.

getting the same in app:

alert(‘test:’ + this.socket.id); // undefined
alert(‘test:’ + this.socket.connected); // false

where do you put the Content-Security-Policy in ?


Are you 100% sure it’s a CSP issue? Have you try to remove it and to test your app on your phone without it?

Have you added some debug logs on your server side? Do you see the connection request there?