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

Support Websocket feature #24

Open
vladigeras opened this issue Jul 15, 2020 · 13 comments
Open

Support Websocket feature #24

vladigeras opened this issue Jul 15, 2020 · 13 comments
Assignees
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects

Comments

@vladigeras
Copy link

Hi!
Thank you for project!
I want to know, can i use it for documenting Spring Websocket functionality?

For example I use next configuration:

@Configuration
@EnableWebSocketMessageBroker
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {
	@Override
	public void configureMessageBroker(MessageBrokerRegistry config) {
		config.enableSimpleBroker("/topic", "/queue");
	}

	@Override
	public void registerStompEndpoints(StompEndpointRegistry registry) {
		registry
				.addEndpoint("/custom-endpoint")
				.setAllowedOrigins("*")
				.withSockJS();
	}
}

And next controller method:

@MessageMapping("/custom-path")
@SendToUser("/queue/custom-path")
public CustomModelResponse getStops(@Payload(required = false) CustomFilter filter) {

	// business logic invocation
        return ...
}

Can I describe it with your project to generate documentation and show it in Swagger like format (like Swagger for REST) and give it to client application? I guess, request, response models and url path will be show inside.
Thank you!

@stavshamir stavshamir added the enhancement New feature or request label Jul 15, 2020
@stavshamir stavshamir added this to Backlog in springwolf Jul 15, 2020
@stavshamir
Copy link
Member

Thanks for the suggestion! Asyncapi specification supports websockets and it looks like enough information can be gathered automatically from the annotations, so this is absolutely doable.

So while springwolf does not support websockets at the moment, definitely expect it in a future version. Also if would like to contribute, we can discuss and design a solution to support it together.

@pixelstuermer
Copy link

Is there any news on this?

@stavshamir
Copy link
Member

Is there any news on this?

Not yet, sorry. If you would like to, I'm open to contributions.

@stavshamir stavshamir added the help wanted Extra attention is needed label Dec 10, 2020
@VeggieTeriyaki
Copy link

Is anyone working on this? I'm interested in bringing this to life :)

@stavshamir
Copy link
Member

That would be great! Work and Covid took most of my available time to contribute to this project.
Let me know if you need guidance or help if you eventually choose to implement this.

@pixelstuermer
Copy link

Is anyone working on this? I'm interested in bringing this to life :)

Nice :) THX for pushing it forward.

@linghengqian
Copy link

Is anyone working on this? I'm interested in bringing this to life :)

I'm happy to see this issue move forward. Is there any progress on this issue?

@stavshamir
Copy link
Member

Is anyone working on this? I'm interested in bringing this to life :)

I'm happy to see this issue move forward. Is there any progress on this issue?

Not yet. Looks like it could be useful though so I'll try tackling this in the close future hopefully.

@stavshamir
Copy link
Member

  • Create new plugin with a channel scanner for web sockets annotations (@MessageMapping, SendTo and @SendToUser)
  • Create an example project
  • @linghengqian We should discuss the name of the plugin - eventhough this is actually STOMP, if the spring dependency, package and classes use the websockets terminology it might be confusing to use a different name here

Another issue is how to implement a springwolf publisher for STOMP like the other plugins have.

In general, I never worked with websockets, so I will appreciate corrections in terminology and code review.

@Crain-32
Copy link

Crain-32 commented May 5, 2022

I'm a step ahead of you a bit. We can use my drafted Plugin PR for reference.

So everything AsyncAPI touches is based on Websockets. HTTP is purely Call-Response (Albeit you can do HTTP-Streams, but that's a separate Topic), where as Websockets allow for Server-Side Events to get pushed to the Client.

STOMP is just like AMQP in that they're just protocols for dictating how the data should get transferred over the Websocket Connection. So stomp-plugin is the correct name, since Spring is expecting (and sending) STOMP frames over the connection.

@linghengqian
Copy link

linghengqian commented May 5, 2022

  • In fact, if you only need websocket support, it is not particularly necessary to introduce spring websocket, so the introduction of spring websocket must actually involve the use of STOMP and sock.js.

  • I think citing Josh Long's explanation in Sping Tips can well understand the role of spring websocket in this place, it appears to integrate STOMP and sock.js (of course sock.js is not a mandatory choice, it is also related to what we are going to discuss irrelevant).

    • Stomp (see https://stomp.github.io/ ) can be used to communicate payloads back and forth from Client to Service via Websocket. STOMP adds some headers, it has a unique area for payloads, so as long as both parties know about you With STOMP, you can communicate. Since websocket itself has no headers, this is a problem if you want to propagate additional information, such as security tokens and the like that are not added to the websocket protocol.

    • sock.js is a javascript library (refer to https://github.com/sockjs/sockjs-node ), which simulates websocket in the browser, even if the browser is not compatible with websocket API. So in theory, you could have an application that degrades gracefully on older browsers , 2022 now we have websocket support naturally, you can count on it being compatible in almost all browsers, but just in case, know that you can still get one Wouldn't a websocket-like API be nice? Via a shim, if you allow you to mimic this behavior, it will work. On the browser side, applications can use sockjs-client . It emulates the W3C WebSocket API and communicates with the server to choose the best transport option, depending on the browser running it. See the sockjs-client page and the list of transport types supported by browsers. The client also provides several configuration options - for example, specifying which transports to include.

  • spring websocket itself provides clients for STOMP and sock.js. Also for NodeJS there are https://github.com/sockjs/sockjs-client/ and https://github.com/jmesnil/stomp-websocket (this library has long since stopped updating, but used its validation before Spring updated its documentation Is it a good choice. Refer to https://docs.spring.io/spring-framework/docs/6.0.0-M3/reference/html/web.html#websocket-stomp-enable )

  • update in 2022.05.18 : After a long struggle with a Discord customer on the mailing list, I finally unblocked my Discord account and confirmed the channel messages.

@stavshamir
Copy link
Member

Closing due to lack of activity. If someone is interested in contributing this, we will consider re-opening.

springwolf automation moved this from Backlog to Done May 23, 2023
@stavshamir stavshamir reopened this Sep 19, 2023
@ctasada
Copy link
Collaborator

ctasada commented Apr 15, 2024

Since we have AsyncAPI support for both STOMP and Websocket, maybe we can take a simple approach providing a simple springwolf-websocket-binding annotation support, like we are now doing for sns or sqs.

WDYT?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
No open projects
springwolf
  
Done
Development

No branches or pull requests

7 participants