This discussion has been migrated from our Github Discussion #5872
maktoobgar247d ago
First of all thanks for creating strapi…
Describe the bug
There is a tutorial about how to use strapi with socket.io side by side but this structure only workes in strapi alpha vesion 3.0.0-alpha.10.1
.
So first time i tried to use it on the latest strapi release 3.0.0-beta.20
, I did exactly everything that happened in the tutorial (the link in Resourse topic) but strapi answers to all client socket requests with 404
response.
Steps to reproduce the behavior
- As tutorial, I created a new strapi project.
- Made a model with “bakery” name and two fields in it (name: string and rating: integer).
- Then i had to give create and find public permission for bakery model to access the model from client side.
- Then add this code to
config/functions/bootstrap.js
:
module.exports = () => { var io = require(‘socket.io’)(strapi.server); io.on(‘connection’, function(socket){ socket.emit(‘hello’, JSON.stringify({message: ‘Hello food lover’})); socket.on(‘disconnect’, () => console.log(‘a user disconnected’)); }); strapi.io = io; };
- Then create
public/bakery.html
and add this code down here to it:
<!doctype html> bakery
Expected behavior
So after these steps your are going to see your bakery.html
windows in your model address localhost:/bakery
in strapi alpha version but…
Unexpected behavior
…in beta there is just 404 not found responses that strapi gives it to me.
strapi exactly blocks socket.io functionality and answers all the requests with 404.
Screenshots
result in strapi beta version:
System
- Node.js version: 12.16.2
- NPM version: 6.14.4
- Strapi version: 3.0.0-beta.20
- Operating system: Ubuntu 18.04.4 LTS
Resource
And this is the tutorial i’m talking about: