Hello,
Actually, I have done nodejs integration with Drupal 8 site.
I have integrated nodejs successfully with my site. But facing an issue with socket.io connection. I am facing the below error in the console:
"http://localhost:8080/socket.io/socket.io.js Failed to load resource: net::ERR_CONNECTION_REFUSE"
I have tried to find out the solution for this and not get the proper doc for this.
Please help me to fix this.
I have attached few files, that will help you to understand the things.
Below are the details:
1. node_modules location: In the root directory ==> /public_html
2. socket.io.js location: /public_html/node_modules/socket.io-client/dist
3. Code of nodejs.config.js:
settings = {
scheme: 'http',
port: 8080,
host: 'domainname.com',
resource: '/socket.io',
serviceKey: 'test',
backend: {
port: 8080,
host: 'domainname.com',
scheme: 'http',
basePath: '',
messagePath: '/nodejs/message'
},
debug: false,
sslKeyPath: '',
sslCertPath: '',
sslCAPath: '',
baseAuthPath: '/nodejs/',
extensions: [],
socketOptions: {}
};
4. For the Drupal backend configuration, I have added the screenshots. Please review.
Please let me know if need more details.
Thank you !!
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | socket-io-config-3170397.patch | 1.54 KB | uniquename |
| nodejs-3.png | 49.34 KB | jayesh_makwana | |
| nodejs-2.png | 44.79 KB | jayesh_makwana |
Comments
Comment #2
imclean commentedFor general support you might have more luck on Drupal Answers: https://drupal.stackexchange.com/questions/tagged/nodejs
Comment #3
mashot7Did you resolve that issue jayesh_makwana?
Comment #4
uniquename commentedI ran into the same problem and found out, that the url for socket.io comes from config/install/nodejs.config.yml, but for whatever reason it is not configurable via the settings form.
I created a quick patch to have those values configurable.
The file is meant to be loaded from the node app. So the url should point to it and it depends on your configuration. I work with ddev and have it exposed on port 3000, so my url is http://ddevd9.ddev.site:3000/socket.io/socket.io.js
Comment #5
imclean commentedI think this is the same problem as the related issue. See the merge request in #3172690: preconfigured socket.io client results in browser error: GET http://localhost:8080/socket.io/socket.io.js net::ERR_CONNECTION_REFUSED.
The setting is already there it's just being ignored.
For a rundown of the configuration options, see my comment here: #2783703-7: Client Socket.io doesn't switch to HTTPS
Comment #6
imclean commentedA quick link to changes in the MR: https://git.drupalcode.org/project/nodejs/-/merge_requests/3/diffs
Comment #7
imclean commentedWhat I should've said is the
socket_ioconfig options don't need to exist. I think the file will always be served by nodejs so a separate setting isn't required.Comment #8
globexplorer commentedHi guys,
I confirm this issue. The reason for that is, that the config form does not show all options possible. If you look in into the config/install folder you will recognize the following data:
But the config form does not show a field referring to that data socket_io. The next function is checking the config, and of course will find it, and therefore always shows the hardcoded value from the config!