react-native-signalr icon indicating copy to clipboard operation
react-native-signalr copied to clipboard

Error during negotiation request. Failed to connect to localhost/127.0.0.1:8888

Open OZhang opened this issue 7 years ago • 4 comments

It's working well when the signalr service deploy on the azure. Thanks. But I also want to debug the signalr serivce on local computer with IIS Express, using code: connection = signalr.hubConnection('http://localhost:8888/'); But it always got error: SignalR error: Error during negotiation request. Failed to connect to localhost/127.0.0.1:8888

Does anybody know how I could fix this issue?

Thanks in advance!

OZhang avatar Oct 14 '17 14:10 OZhang

Don't know why it fails. Have you tried running it by using IIS and not IIS express? I used IIS locally.

olofd avatar Oct 31 '17 11:10 olofd

Issue with the http://localhost:8888

connection = signalr.hubConnection('http://localhost:8888/');

Try with your network IP address and it will solve your issue.

windows command prompt (cmd) enter ipconfig

Example, connection = signalr.hubConnection('http://192.168.1.20:8888/');

Also check followings,

  • host SignalR in Local IIS not IIS Express
  • enable Web Socket in IIS (Enable Windows Features > IIS)

chinthaka24 avatar May 26 '18 11:05 chinthaka24

I have the same error.

smemamian avatar Mar 05 '19 18:03 smemamian

I have the same issue

package.json "{ "name": "ChatApp", "version": "0.0.1", "private": true, "scripts": { "start": "react-native start", "test": "jest", "lint": "eslint ." }, "dependencies": {

"react": "16.8.6",
"react-native": "0.60.5",
"react-native-signalr": "^1.0.6"

}, "devDependencies": { "@babel/core": "^7.5.5", "@babel/runtime": "^7.5.5", "@react-native-community/eslint-config": "^0.0.5", "babel-jest": "^24.9.0", "eslint": "^6.2.2", "jest": "^24.9.0", "metro-react-native-babel-preset": "^0.56.0", "react-test-renderer": "16.8.6" }, "jest": { "preset": "react-native" } }" App.js

import React, {Component} from 'react'; import { SafeAreaView, StyleSheet, ScrollView, View, Text, StatusBar, } from 'react-native';

import signalr from "react-native-signalr"; class App extends Component{ constructor(props){ super(props)

}; componentDidMount() { const hubUrl = 'http://localhost:82//signalr/hubs';

const connection = signalr.hubConnection("http://localhost:82/"); connection.url =hubUrl connection.logging = true;

const proxy = connection.createHubProxy('chatHub');

proxy.on('broadcastChat', (result) => { console.log('message-from-server', result);

});

// atempt connection, and handle errors connection.start().done(() => { console.log('Now connected, connection ID=' + connection.id);

proxy.invoke('getUsers')
  .done((directResponse) => {
    console.log('direct-response-from-server', directResponse);
  }).fail(() => {
    console.warn('Something went wrong when calling server, it might not be up and running?')
  });

}).fail((e) => { console.log('connection',connection); console.log('Failed',e); });

//connection-handling connection.connectionSlow(() => { console.log('We are currently experiencing difficulties with the connection.') });

connection.error((error) => { const errorMessage = error.message; let detailedError = ''; if (error.source && error.source._response) { detailedError = error.source._response; } if (detailedError === 'An SSL error has occurred and a secure connection to the server cannot be made.') { console.log('When using react-native-signalr on ios with http remember to enable http in App Transport Security https://github.com/olofd/react-native-signalr/issues/14') } console.debug('SignalR error: ' + errorMessage, detailedError) });

render() { console.log(this.state) return ( <View></View> ); }; } }

export default App;

sujanmah062 avatar Aug 28 '19 08:08 sujanmah062