React-native: responseType "arraybuffer" is unsupported

Created on 31 Mar 2016  路  5Comments  路  Source: facebook/react-native

I updated to 0.22.2 and now my socket.io code crashes and i get the following error message:

screen shot 2016-03-31 at 14 14 29

I just call

var io = require('socket.io-client/socket.io');
this.socket = io(this.chatUrl, {jsonp: false});

My environment: osx 10.11.3, iPhone 6 iOS 9.0 Simulator.

Locked

Most helpful comment

My solution is to add

 transports: ['websocket']

to the io constructor configuration, so socket.io will use websocket only.

I tried to modify the XMLHttpRequestBase.js, although there is no error thrown, but it seems the socket is not receiving or sending correctly.

All 5 comments

My workaround is extending the function _didReceiveData in the XMLHttpRequestBase.js file (react-native/Libraries/Network) like this:

  .............
  case 'arraybuffer':
    this.response = new Uint8Array(this.responseText.length);
    break;
  default: //TODO: Support other types, eg: document, arraybuffer, json
    invariant(false, `responseType "${this.responseType}" is unsupported`);
  }
  .............

But i am not sure if this is the correct way!

My solution is to add

 transports: ['websocket']

to the io constructor configuration, so socket.io will use websocket only.

I tried to modify the XMLHttpRequestBase.js, although there is no error thrown, but it seems the socket is not receiving or sending correctly.

Thank you very much! It helped me after update react-native form 0.17.0 to 0.24.0
i received from socket.io server error with code: "parse error", when tried connect to socket.io server

Maybe a dup / can be merged with #1424 ?

Closing this in favor of the issue grabbou mentioned above

Was this page helpful?
0 / 5 - 0 ratings