-
Notifications
You must be signed in to change notification settings - Fork 42
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
Service channels & websockets only #2
Comments
Sure, I'd love to help you, and in the meantime we might discover/fix some bugs as well. 😉
client = Client("http://example.com/cometd",
connection_types=ConnectionType.WEBSOCKET)
So I think everything you want to use is already supported. |
Hey @robertmrk ,
I will still dig just to make sure I'm not bypassing an HTTP/long-polling endpoint by mistake but if I'm not, my thought here was to detect if the connection URL's protocol is non-HTTP (e.g.
Lastly, I've cleared up the logs here.
The Thanks for the help! P.S. The server I'm connecting to runs Jetty |
As far as I know (somebody please correct me if I'm wrong here), there is no such thing as a bayeux server without support for
What you're actually trying to achieve here is to skip the connection negotiation step entirely, which I think is not feasible. |
BTW. There is nothing special about service channels, at least not on the client side. |
Got it, thank you. I'll do some more digging on my side. Hopefully figuring out the first point will automatically solve the second. |
Hey @robertmrk , so an update: I went back to basics and did some more investigation; I opened a basic test/debug site from the same service provider I'm trying to connect to and tried to do a 'by-the-example'
This connects successfully and looking at the Chromium traffic inspector you can see the websocket connection formed and working.
I would really appreciate it if you could have a look and give me some insight as to why that may be the case and what the best steps forward are? Thank you! |
I can see that the site uses the official cometd implementation and it indeed seems to do even the first handshake with the import asyncio
from aiocometd import Client, ConnectionType
import aiocometd.client
async def main():
aiocometd.client.DEFAULT_CONNECTION_TYPE = ConnectionType.WEBSOCKET
async with Client("https://tools.dxfeed.com/webservice/cometd") as client:
async for message in client:
print(message)
if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(main()) To solve or test your other issues, I would need to trace what the official client does on https://tools.dxfeed.com/webservice/debug-console.jsp |
Thank you for the information. That's very useful for me to know. I'd be very happy to contribute a PR to
You'll see in your Network inspector that there will be a websocket connection made |
@boyan-soubachov So the specifications allow 2 simultaneous connections for HTTP based transports. In fact, 2 connections are the minimum for them to be able to use them in full duplex mode. While for non HTTP transports like the TL;DR; The websocket transport needs to be implemented using a single connection to solve this problem. Normally I would be more than happy to accept PRs, but I plan to implement this myself, since I know how tricky it is to implement the automatic reconnection, and network outage detection features of the library with websockets. But it would be very useful if you could help me with the testing of this fix with a real world workload. I'll soon create a new feature branch for testing this. |
Thank you, @robertmrk ! This is very useful to know. I'm happy to test the proposed change/branch. I will modify my code to set the Do you plan to implement this as a parameter/option or do you want to make it the default. I'm not too familiar with the Bayeux protocol specification but from a very quick guess, it seems to me like a better idea to make 1 connection the default since it would be more widely supported given what you say? |
Please try connect to dxfeed with the implementation from the branch $ pip install -e git+https://github.com/robertmrk/aiocometd.git@feature/single-connection-websocket#egg=aiocometd If it works, then this will be the new implementation for |
That seems to have done the trick! I've got some major fixes to do on my side but everything looks good for now. Thank you! I will let you know if I stumble across anything in the future but will switch over to |
You're welcome! |
Hi @robertmrk ,
I'm the author and maintainer of another repo where I've had to hardcode my own Bayeux implementation. I'd really like to switch to using your aiocometd as it looks fantastic but after days of toiling I've discovered 2 things:
I'd like to help implement these if possible; point
1
is relatively easy for me as I've been digging around and modifying the code but point2
has me stumped and I keep getting402 :: Unknown client
from the remote server when I try to 'fake' the service channel requests throughpublish()
.Example below of what my traffic looks like:
Any help and advice is greatly appreciated 😄
The text was updated successfully, but these errors were encountered: