Replies: 7 comments 14 replies
-
Can you be able to help with this issue? Would be glad you check this out. |
Beta Was this translation helpful? Give feedback.
-
It looks like you didn't boot socket.io. The code below must be in your provider: import { ApplicationContract } from '@ioc:Adonis/Core/Application'
export default class AppProvider {
constructor(protected app: ApplicationContract) {}
public async ready() {
if (this.app.environment === 'web') {
await import('../start/socket')
}
}
} If it doesn't help, create a repository to reproduce the error |
Beta Was this translation helpful? Give feedback.
-
okay, let me try this. |
Beta Was this translation helpful? Give feedback.
-
I also had the same problem even though I followed all the steps as in Adonis's tutorial. |
Beta Was this translation helpful? Give feedback.
-
Try this: // app/Services/Ws.ts
...
this.io = new Server(3000, {
cors: {
origin: 'http://localhost:3333',
allowedHeaders: ['Access-Control-Allow-Origin'],
},
}); Also for some reason, this also works: this.io = new Server(3000, { cors: {} }); ^ That's whether the |
Beta Was this translation helpful? Give feedback.
-
Any updates for this issue guys?, I had the same problem but still not fixed yet. Please guys, let me know if there's a way to fix it |
Beta Was this translation helpful? Give feedback.
-
any news about websockets with adonis v6? |
Beta Was this translation helpful? Give feedback.
-
Problem statement
I am using AdonisJs with socket.io, and I followed the documentation for using with socket.io
When on the Ws Service Class,
using this code provided by the docs does not instantiate the socket and always returns 404 not found /socket.io/
But when I change the socket to use a different port, I was able to connect to the socket.
Actual Results
When using this code works and I am able to connect to socket.io from the client using
ws://localhost:3000
meanwhile app server is running on port3333
Expect Results
From the docs, this code should allow a socket connection.
Package version
AdonisJs Version 5
Node.js and npm version
Node v18.15.0
NPM 9.5.0
Sample Code (to reproduce the issue)
Beta Was this translation helpful? Give feedback.
All reactions