-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Create WebSocket example #253
Comments
I had the same question while working on this demo application: https://github.com/treeder/async-toy-store I ended up wrapping the messages in metadata that included the channel name: https://github.com/treeder/async-toy-store/blob/master/models/message.go Not sure how to describe that in AsyncAPI though. |
Hey folks! I just created a code generator for Node.js and WebSockets. With it, I created an example of an echo client/server using WebSockets. Check it out: https://github.com/fmvilas/asyncapi-websockets-example. The AsyncAPI file is this one: https://github.com/fmvilas/asyncapi-websockets-example/blob/master/asyncapi.yaml. Hope it helps! |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
It is still needed to have WS example among other examples basing on this thread https://asyncapi.slack.com/archives/C34F2JV0U/p1583757080132600, not to mention that it would make sense to have a documentation that explains the example |
This issue has been automatically marked as stale because it has not had recent activity 😴 |
This issue has been automatically marked as stale because it has not had recent activity 😴 |
I think that this could be my next “assignment”. I’d love to do as much as possible here:
What do you think should be my focus. What would you like to see there, what should I showcase? What would you love to get as a user? 🤔 |
I'd make sure the project showcases:
|
Would love to see an example for internal communication in terms of Node.js + Socket.io server and client 🙇 |
Nice initiative really fill a hole in the OpenAPI Spec! I'm trying to model a WS API with the AsyncAPI Spec, I have PUBLISH, SUBSCRIBE but also UNSUBSCRIBE operations, where do you put these operations inside the PUBLISH section? Or am I missing Also, I read your article @fmvilas about organizing your AsyncAPI documents I understood you recommend doing two AsyncAPI documents, one for the client perspective and one from the server perspective. Do you have an example available with the two documents? I understand in more complex systems with a lot of different consumers/producers it may be interesting to have multiple documents, still, a document to explain the whole system is nice to have. In a WS scenario, what is missing to achieve this, is a field to indicate who can subscribe, and who publishes a message, with WS in mind since there are only two members is easy to identify the member at the other end. Thanks for your help |
Hey @lbdremy!
Yeah, we don't consider unsubscribe as an operation in the spec. An unsubscribe operation is actually a Now regarding the file organization, I think in the case of a client/server WebSockets connection, it doesn't make sense to have multiple AsyncAPI files. You could just have one as you do with OpenAPI for instance. The AsyncAPI file represents the server and the The difference with a broker architecture here is that this pattern —even though it's messaging— is not broker-based but instead it follows the "traditional" client/server architecture and the connection is connecting both the client and the server directly, as in an HTTP API. That's why in these cases, I think it makes sense to have only one file for the server and the client just takes it for reference. Hope that helps :) |
Yes it helps :) thanks @fmvilas
I agree one OpenAPI file to describe is much better still, in my case, the Thanks again for your help :) |
This is the meaning of
Who is "the app" here? Is it the client? If it's the client this case is still a Usually, the trick here is to think about the communication always from the client perspective. You define what the client can/will do. Therefore, saying that a client can |
Hi, regarding the initial question I would like to know if I get it right based on the following information:
That means when I'm trying to model an API between two micro services that is based on Websockets, I essentially ending up defining a single Channel where Thanks |
I wrote two articles about describing WebSockets with AsyncAPI that should explain the relationship between the two and how to use AsyncAPI to describe WebSocket API. It is based on real WebSocket API (single channel) as I could not come up with a better artificial example. Life is better in creating different scenarios.
I want to also record a live stream about the above, to basically provide the same content in audio and video. I plan one article more + a presentation on a conference. The plan is to write a super basic file (multi-channel) and do some code generation with it. I was thinking about writing a new template from scratch using socket.io (as suggested above) but after playing with https://github.com/asyncapi/nodejs-ws-template I think it is a good and very simple template suitable for education. Let's see where it goes. Let me know what you think. If you know a technical writer or just anyone good at docs, that has time to contribute to open-source, please connect us. Would be great if someone can help, grab my content, do some Q&A sessions and create official documentation that we could host on our AsyncAPI website 🙏🏼 |
|
Last blog post is out https://www.asyncapi.com/blog/websocket-part3 Let me close this issue and please let me know in a new issue if something more is needed |
@fmvilas We have a microservices based internal pub-sub architecture, and we have webhooks as interfaces to third party applications. I was looking to use AsyncApi as my single source of truth for my internal and external APIs. Looks like that isn't possible yet. |
@Jaikant Yeah, still not possible. Would be awesome if you create an issue to request for this functionality and maybe even champion it :) |
Could you please provide WebSocket AsyncAPI 2.0.0 complete example.
Right now I totally misunderstand how to describe single channel (i.e. I use only one path "/ws" for example) RPC service with messages like SignUpRequest, SignUpResponse, etc.
The text was updated successfully, but these errors were encountered: