Cannot connect to socket.IO in native while browser can

Cannot connect to socket.IO in native while browser can
0.0 0


Hi, i cant connect to my server in simulator, android, while i can connect succesfully using browser ( Chrome)

My setup :
Cocos Creator : 1.7
Browser : Chrome
Server : 2.0.4

In simulator and android, it automatically disconnect when i call connect. ( I can connect to ws:// )

In my socket.IO server , i see that the socket.handshake of browser and native platform is different :

 ==========Browser connect===============
{ headers:
   { host: '',
     connection: 'keep-alive',
     accept: '*/*',
     origin: 'http://localhost:7456',
     'user-agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36
(KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36',
     referer: 'http://localhost:7456/',
     'accept-encoding': 'gzip, deflate',
     'accept-language': 'vi-VN,vi;q=0.9,en-US;q=0.8,en;q=0.7,fr-FR;q=0.6,fr;q=0
     cookie: 'io=q8CuM0Vv8MZB-cRvAAAB' },
  time: 'Thu Jan 04 2018 20:22:33 GMT+0700 (SE Asia Standard Time)',
  address: '::ffff:',
  xdomain: true,
  secure: false,
  issued: 1515072153234,
  url: '/
   { token: '6ad5f1be-53f2a858e7e48fee584c05',
     EIO: '3',
     transport: 'polling',
     t: 'M31Leh6' } }

==========Native connect===============
{ headers:
   { host: '',
     accept: '*/*',
     'accept-encoding': 'identity' },
  time: 'Thu Jan 04 2018 20:23:08 GMT+0700 (SE Asia Standard Time)',
  address: '::ffff:',
  xdomain: false,
  secure: false,
  issued: 1515072188157,
  url: '/',
  query: { EIO: '2', transport: 'polling', b64: 'true' } }


It seem different in the xdomain, the url path and EIO protocol, and the query is not taken along with in native platform


Hmm as i read and google, cocos only connect to 0.9 while i am using 2.04, and in trello they delay the update to latest version…


I am using 1.4.8 and working fine.


I switch to 0.9.7, my native app works but in browser now have CORS problem :slight_smile:

Failed to load No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:7456’ is therefore not allowed access.