Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unrecognized WebSocket connection option(s) `agent`, `perMessageDeflate`, `pfx`, `key`, `passphrase`... Did you mean to put these under `headers`?

Have you ever met this message in a React Native application using a WebSocket ( SocketIOClient from 'socket.io-client') ?...

Unrecognized WebSocket connection option(s) `agent`, `perMessageDeflate`, `pfx`, `key`, `passphrase`, `cert`, `ca`, `ciphers`, `rejectUnauthorized`. Did you mean to put these under `headers`?
like image 941
L.G Avatar asked Dec 05 '18 18:12

L.G


2 Answers

Yes, this is happening in the WebSocket class constructor in Socket.io. I think it happens when you specify your transport layer as 'websocket' in the constructor (which is necessary for React Native socket io use). It doesn't do anything bad, but is annoying. You can get rid of it with the react-native YellowBox.ignoreWarnings: When initiating your app:

console.ignoredYellowBox = ['Remote debugger'];
import { YellowBox } from 'react-native';
YellowBox.ignoreWarnings([
    'Unrecognized WebSocket connection option(s) `agent`, `perMessageDeflate`, `pfx`, `key`, `passphrase`, `cert`, `ca`, `ciphers`, `rejectUnauthorized`. Did you mean to put these under `headers`?'
]);
like image 70
Dave Welling Avatar answered Sep 20 '22 15:09

Dave Welling


The one way to remove the error:

let socket = io.connect(SOCKET_URL, {
  timeout: 10000,
  jsonp: false,
  transports: [‘websocket’],
  autoConnect: false,
  agent: ‘-’,
  path: ‘/’, // Whatever your path is
  pfx: ‘-’,
  key: token, // Using token-based auth.
  passphrase: cookie, // Using cookie auth.
  cert: ‘-’,
  ca: ‘-’,
  ciphers: ‘-’,
  rejectUnauthorized: ‘-’,
  perMessageDeflate: ‘-’
});
like image 24
Hari Avatar answered Sep 18 '22 15:09

Hari