I'm runing a localhost adonisjs project with a websocket. I followed the adonis get started here. Everything in the server looks ok, but when I tried to connect in my react-native application a got this error:
{
"isTrusted": false,
"message": "Expected HTTP 101 response but was '400 Bad Request'",
}
This is my cliente code:
const ws = new WebSocket("ws://192.168.0.11:3333")
ws.onopen = () => {
ws.send(JSON.stringify({
t: 1,
d: { topic: 'prelista:5999c0ea-6bbb-4e0f-9496-f62658bbac5' }
}))
}
ws.onmessage = (e) => {
console.log(e)
}
ws.onerror = (event) => {
console.log(event)
}
This is my server code:
'use strict'
const Ws = use('Ws')
Ws.channel('prelista:*', ({ socket }) => {
console.log(socket.topic)
})