Comments (23)
Same problem here, all socket.io funcionalities in my app have stoped with Monitor installed.
from express-status-monitor.
@waltergms
if you already use socket.io, remove the engine.io dependencies from package.json, and set it up with your socket.io deps instead. Replace the engine io with socket.io client eio.on('conn..
-> io.of('/status').on('conn
where eio = engine.io server and io = your socket.io server - and in client replace eio('...
with io('/status'
from express-status-monitor.
app.use(require('express-status-monitor')({ websocket: existingSocketIoInstance }))
is great idea. I'll try to implement that asap. Thanks for input guys, I really appreciate it.
from express-status-monitor.
I think might be resolved by this upcoming change: https://github.com/RafalWilinski/express-status-monitor/pull/62/files
What I'm doing here is allowing to "hook" express-status-monitor events into existing socket.io instance.
from express-status-monitor.
Very interesting case, I'll dig into that topic in the next days. I suppose that may be related to clashing socket.io event names.
Thanks for letting me know!
from express-status-monitor.
No worries - let me know if you need me to test anything.
Error is:
socket.io.js:4026 WebSocket connection to 'ws://localhost:3000/socket.io/?EIO=3&transport=websocket&sid=r-kwtVh_JrVyjoNmAAAB' failed: Connection closed before receiving a handshake response
Note that ESM seems to survive, and my socket.io functionality fails, but I suspect that's just the order of the implementation, so an option to prevent the clash might be handy.
from express-status-monitor.
You need to match your socket.io-client library on the clientside to the ^1.4.* that express-status-monitor uses, as well as refactor your connection.on and session handling code, especially if you're using older socket.io ( I've some servers running socket.io-0.9.* which don't play nice with >1.0.0 after ) I've already lost the upgrade-path I used to update beyond that, but it wasn't that hard to do.
EDIT: Not promising anything timeline-wise (haven't even forked ESM yet) but I could pull it to one of the older socket-servers, and test whether I can downgrade ESM to use previous version / upgrade (documenting changes) an older socket-io server to match 1.4.* in the near(-ish) future
UPDATE: Forked to branch esm-downgrade at https://github.com/jabis/express-status-monitor
I managed to get it running properly on older express, and socket.io < 1.0.0
Added a couple of environment variables to config to comply with older spec, used http.createServer wrapping so both socket.io and app can have listen passthru, next I'll try namespace it out and, integrate it with a running app-server, and we'll see if it conflicts.
from express-status-monitor.
Managed to integrate with existing socket.io as long as the version of both server and client is of same series and unique namespace is used. 2 distinct socket.io server services clash.
I'm running our own api stack on top of express using a modified vhosts-routing, so I always expose the root-io as a global
and vhosts all attach their own namespaces to it, so it took me about a minute to add the config variables, and include the app.use passing the server/socket.io instance after downgrading.
from express-status-monitor.
Wow - nice work. Will check it out ASAP and see if it fixes my issue.
from express-status-monitor.
It needs quite a bit more love (I had to embed the old socket.io client to the html-file which is ugly because I was testing it locally first), but as PoC I think you can find the relevant bits there :) Note this was for version ^0.9.16, haven't the time to tackle upgrading the socket servers yet, as doing client work (regarding sockets, unsurprisingly)
from express-status-monitor.
I'm having the same issue. My socket.io instance also uses ^1.4.*
, it still doesn't work. When I remove express-status-monitor, my socket.io instance works fine, otherwise I keep getting Connection closed before receiving a handshake response
.
Is there any way to re-use the existing socket.io instance yet?
from express-status-monitor.
@omnidan I managed to use the existing socket.io instance just as I described above - replacing the engine io deps with socket.io ones, and the initializers with a namespace.
from express-status-monitor.
@jabis I don't use engine.io though - the only dependency I have in my package.json is socket.io
. Also, what do you mean by "replace the initializers with a namespace"?
from express-status-monitor.
@omnidan when you install the express-status-monitor, it has a package.json - there is engine.io and engine.io-client references there (which supercede socket.io in a manner of way) and like I posted earlier instead of using eio.on('connection')
use io.of('/status').on('connection')
and on the clientside eio('...options...)
use io('/status')
to override the default namespace (and ofc make sure you reference the eio/io with the actual variable for them required socket.io and socket.io-client's packages. Should be that straightforward :)
from express-status-monitor.
@jabis Thanks for the explanation! Unfortunately, that would mean that I have to fork express-status-monitor
(changing directly in node_modules
won't make it work everywhere). Would be nice if this could get fixed in this repo, or maybe an option to pass an existing socket.io instance.
from express-status-monitor.
@omnidan unfortunately it's not my repo so I can't fix this for you :) Also I don't think @AussieFlem will want to change the dependencies to much larger bundle (eio vs io) and it would basically mean a refactor for componizating the whole piece of software to cater for different audiences, as this basically is just a "middleware" per sé. Not only is it conflicting with prior socket.io and engine io releases I suppose it conflicts with every websocket lib instance there is, so it wouldn't be a minor feat. That's actually why I wrote the downgraded version in the first place :) Maybe @AussieFlem though could namespace the lib to a meaningful name, so that it wouldn't hog the default ('/')
namespace though?
from express-status-monitor.
@jabis Wouldn't it be possible to allow passing an existing socket.io instance and avoid the dependency altogether?
from express-status-monitor.
@omnidan I don't think that npm at least allows conditional dependencies in that sence. The problem mostly lies in the installation process for starters, and adds up upon possible conflicting socket lib used. I guess it could be made a proper middleware though, but I think there is much to go thru in the codebase to reach that point - my advice would be to fork it and keep on top of the changes :)
from express-status-monitor.
@jabis I understand that, what I'm talking about is an option in the api config to pass an existing socket.io instance, you could still fall back to eio if no instance is specified.
from express-status-monitor.
@omnidan I get what you're meaning, but when you actually install it and it processes the dependencies you might end up messing your existing socket instance before using it - I suppose the way you suggest would be the best option though - to make it a proper middleware passing along the server and socket instances to bind to - though it doesn't quite address the main problem here :)
from express-status-monitor.
@jabis I don't think installing eio will make any difference - I actually still have express-status-monitor
installed (I just don't do app.use(require('express-status-monitor')())
) and it works fine. So my proposal would be something like this:
app.use(require('express-status-monitor')({ websocket: existingSocketIoInstance }))
from express-status-monitor.
@omnidan yes that's exactly what I'm proposing - though you're wrong in the first assumption - the installed version of socket lib vs the one used on esm does actually make a difference (believe me I've tried :D ) :)
from express-status-monitor.
@jabis It's not making any difference for me, but maybe it does if you're using an older version of socket.io (I'm using the latest version while this package uses 1.4)
from express-status-monitor.
Related Issues (20)
- Socket.io extra headers
- Installation on centos 7 HOT 1
- Package breaks with non-vulnerable Socket.Io version 4.1.2 HOT 1
- Cannot access status path HOT 3
- Not working on MacOS Safari, iOS browsers. HOT 2
- Own Socket instance? HOT 2
- Critical security vulnerability HOT 1
- ES5 import clause HOT 1
- Synk security issues
- ```healthcheck``` Failed for succesful host request
- Breaking changes on security update for socket.io-parser
- How to graceful shutdown HOT 2
- event-loop-stats not found, ignoring event loop metrics HOT 1
- Alert And Notification HOT 2
- Not working when running as root on a raspberry pi
- WebSocket connection to '<URL>' failed: WebSocket is closed before the connection is established. HOT 2
- Doesn't play well with vitest
- Dark UI proposal
- Add new field for report
- cannot pass header into endpoint healthcheck
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from express-status-monitor.