React Native and using websockets

Viewed 4457

I have such code with react-native@0.17

import React, { AsyncStorage, Component, View, Text, WebView, WebSocket } from 'react-native';
import { Avatar, Divider, Subheader, COLOR } from 'react-native-material-design';

export default class Avatars extends Component {
    _setWebSocket = (endpoint, sessionToken) => {
      const ws = new WebSocket('wss://' + endPoint + '/api/live?authToken=' + sessionToken);
      console.log('Setting socket: ' + 'wss://' + endpoint + '/api/live?authToken=' + sessionToken);

and I'm calling code from:

componentDidMount() {
   this._setWebSocket(endpoint, token);
 }

I have issue with trying to get WebSockets to be working as code:

console.log('Setting socket: ' + 'wss://' + endpoint + '/api/live?authToken=' + sessionToken); 

never is triggered . If I put console log before creating new WebSocket it runs. What I'm doing wrong and how can I debug as chrome isn't showing useful information in combination with Genymotion.

1 Answers
Related