-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom namespace to avoid conflict with existing Socket.io implementation? #27
Comments
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! |
No worries - let me know if you need me to test anything. Error is:
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. |
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 UPDATE: Forked to branch esm-downgrade at https://github.com/jabis/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. |
Wow - nice work. Will check it out ASAP and see if it fixes my issue. |
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) |
Same problem here, all socket.io funcionalities in my app have stoped with Monitor installed. |
@waltergms |
I'm having the same issue. My socket.io instance also uses Is there any way to re-use the existing socket.io instance yet? |
@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. |
@jabis I don't use engine.io though - the only dependency I have in my package.json is |
@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 |
@jabis Thanks for the explanation! Unfortunately, that would mean that I have to fork |
@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 |
@jabis Wouldn't it be possible to allow passing an existing socket.io instance and avoid the dependency altogether? |
@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 :) |
@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. |
@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 :) |
@jabis I don't think installing eio will make any difference - I actually still have
|
@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 ) :) |
@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) |
|
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. |
I plugged e-s-m into our web application with an existing socket.io component, and whilst the monitor system worked it knocked out our existing functionality with a handshaking problem.
I suspect one socket-io killed the other.
Would allowing the specification of namespace allow it to run alongside an existing socket.io implementation, or is it one socket.io per server?
Alternatively, can it be set to use an existing socket.io setup if it's present, and create it's own if not?
I haven't dug through the source, just thought I'd put it out there in case you knew off the top of your head.
The text was updated successfully, but these errors were encountered: