Code Monkey home page Code Monkey logo

Comments (4)

olofd avatar olofd commented on June 9, 2024

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

from react-native-signalr.

chinthaka24 avatar chinthaka24 commented on June 9, 2024

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)

from react-native-signalr.

smemamian avatar smemamian commented on June 9, 2024

I have the same error.

from react-native-signalr.

sujanmah062 avatar sujanmah062 commented on June 9, 2024

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 #14')
}
console.debug('SignalR error: ' + errorMessage, detailedError)
});

render()
{
console.log(this.state)
return (

);
};
}
}

export default App;

from react-native-signalr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.