Skip to content
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

Add feature to ignore only some unhandled messages #194

Conversation

Jonnern
Copy link
Contributor

@Jonnern Jonnern commented Mar 22, 2024

I think setting UnhandledMessageExpected = true may hide too many messages. Let's say the exchange sends some messages you don't want to handle and you need to enable UnhandledMessageExpected to avoid noise in the log.

By adding the property HashSet<string>? IgnoredUnhandledMessages in SocketApiClient, you can ignore a set of unhandled messages and log the messages that are not ignored.

I added a test case where a "connected" message is ignored and "unhandled" will be logged.

@Jonnern Jonnern force-pushed the feature/customized-ignore-unhandled-message branch from 1bc2251 to 498eb28 Compare March 25, 2024 09:04
@Jonnern Jonnern marked this pull request as ready for review April 4, 2024 06:25
@Jonnern Jonnern requested a review from JKorf April 6, 2024 11:53
@JKorf
Copy link
Owner

JKorf commented Apr 16, 2024

Have you encountered this to be a problem in a certain scenario?

@Jonnern
Copy link
Contributor Author

Jonnern commented Apr 16, 2024

Have you encountered this to be a problem in a certain scenario?

Yes, I made a wrapper around the CexIo API and it sends a connected message when you connect the socket
{"e":"connected"} https://trade.cex.io/docs/#websocket-public-api-calls

As I don't want to ignore every unhandled message, I want to ignore only specific messages like this one

@JKorf
Copy link
Owner

JKorf commented Apr 16, 2024

If you look at the Kraken socket client you can see that it registers a HeartbeatSubscription. It doesn't specifically have a purpose other then receiving the server sent heartbeat messages. You could do something similar which I feel is a bit cleaner way.

https://github.com/JKorf/Kraken.Net/blob/14b790ddff5d1ae76909e40d99897dca733af757/Kraken.Net/Clients/SpotApi/KrakenSocketClientSpotApi.cs#L62

@Jonnern
Copy link
Contributor Author

Jonnern commented Apr 24, 2024

I forgot that I could add that as a SystemSubscription. Thanks for the advice

09:31:13:230 CexIo: Debug: [Sckt 1] connected to wss://trade.cex.io/api/spot/ws-public
09:31:13:230 CexIo: Debug: [Sckt 1] status changed from None to Connected
09:31:13:230 CexIo: Debug: [Sckt 1] starting processing tasks
09:31:13:230 CexIo: Trace: [Sckt 1] received 17 bytes in single message
09:31:13:230 CexIo: Trace: [Sckt 1] received {"e":"connected"}
09:31:13:230 CexIo: Trace: [Sckt 1] 1 processor(s) matched to message with listener identifier connected

@Jonnern Jonnern closed this Apr 24, 2024
@Jonnern Jonnern deleted the feature/customized-ignore-unhandled-message branch April 24, 2024 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants