react-native-network-proxy icon indicating copy to clipboard operation
react-native-network-proxy copied to clipboard

Cannot send a message. Unknown Websocket id 2

Open jurajkrivda opened this issue 8 years ago • 8 comments

Hello. I imported your example code to my project and I got this message Cannot send a message. Unknown Websocket id 2

jurajkrivda avatar Jul 03 '17 11:07 jurajkrivda

Hi @jurajkrivda!

Hm, I haven't seen this issue before. Can you please provide the code which is failing? It'll help me to figure out what went wrong.

Thanks in advance 🚀

Kureev avatar Jul 03 '17 13:07 Kureev

Hello @Kureev here you are:

import React, { Component } from 'react';
import { AppRegistry } from 'react-native';
import { ApolloProvider } from 'react-apollo';
import SplashScreen from 'react-native-splash-screen';
import Layout from './routes';
import client from './apollo/client';
import createStore from './store/store';
import { AlertProvider } from './components/Alert';

import { start as startNetworkDebugging } from 'react-native-network-proxy';

startNetworkDebugging();

const store = createStore(client);

class App extends Component { // eslint-disable-line
  componentDidMount() {
    SplashScreen.hide();
  }

  render() {
    return (
      <ApolloProvider
        client={ client }
        store={ store }
      >
        <AlertProvider>
          <Layout />
        </AlertProvider>
      </ApolloProvider>
    );
  }
}

console.disableYellowBox = true;

AppRegistry.registerComponent('App', () => App);

Almost forgot. This error is only displayed when you request a GraphQL mutation or query. I use Apollo client.

jurajkrivda avatar Jul 03 '17 18:07 jurajkrivda

Thanks for the code! I'll try to reproduce it in a few hours and report back.

Kureev avatar Jul 04 '17 07:07 Kureev

Hi @jurajkrivda!

I finally found some time to investigate this issue (even though it tool longer than I expected). I've tried to use https://github.com/apollographql/frontpage-react-native-app as an example of an average RN + Apollo app and it seems to work.

There is one thing you might miss:

  • In the readme, after installation instruction, there is a command yarn react-native-network-proxy. Are you sure you run it?

Nevertheless, I found a header encoding issue. But that's a different topic for discussion.

Can you please double-check your setup one more time so we can find an another way to fix the problem?

Kureev avatar Jul 09 '17 21:07 Kureev

Hi @Kureev!

I'm sure of my configuration. After I installed this library I started proxy with yarn react-native-network-proxy. I use the latest React Native version but version 0.33 is used in your Apollo example. Could you upgrade your dependencies? I also send authorization tokens in all requests headers.

jurajkrivda avatar Jul 12 '17 12:07 jurajkrivda

Unfortunately, it isn't my repo. I updated dependencies manually in order to make it work with react-native-network-proxy (XHRInterceptor has been introduced in the latest versions). I'll create an examples folder and add apollo example there.

Kureev avatar Jul 13 '17 08:07 Kureev

@Kureev Thank you.

jurajkrivda avatar Jul 13 '17 10:07 jurajkrivda

this appears to be an issue with react-native https://github.com/facebook/react-native/issues/17494

sonnyp avatar Jan 12 '18 16:01 sonnyp