React-Native and AutobahnJS
I am trying to set up a connection with a WebSocket server in a React-Native application using the npm package react-native-autobahnjs.
Here is my code :
import autobahn from 'react-native-autobahnjs';
class websocket extends Component {
componentWillMount () {
console.warn("MOUNTING MAIN COMPONENT");
const connection = new autobahn.Connection({
url: 'wss://myserver/ws',
realm: 'realm1'
});
connection.onopen = () => {
console.warn("onopen");
};
connection.onclose = (reason, details) => {
console.warn("onclose : reason = " + reason + ", details = " + details);
};
console.warn("connection.open()");
connection.open();
}
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
autobahn.js test page
</Text>
</View>
);
}
}
I get the following warning : onclose : reason = unsupported, details = [object Object]
What is going wrong? Thank you.
Comments
Post a Comment