livepersoninc / dropwizard-websockets Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
as stated from your example:
public void initialize(Bootstrap bootstrap) {
websocketBundle = new WebsocketBundle();
bootstrap.addBundle(websocketBundle);
}
is not an actual constructor.
We're still using Jetty 9.4.10
while the current version is already 9.4.18
.
There's at least one breaking change in 9.4.17:
- 3464 Split SslContextFactory into Client and Server
which blows up my current project for another dependency in my fat jar includes a 9.4.18
jetty leading to a NoClassDefFoundError
.
Can we upgrade to the latest jetty version? I'll try to file a PR if I find some spare time.
Hi,
I'm using Dropwizard 1.0.5 with the 1.0.0-1 version of the plugin.
Tried this example.
The AnnotatedEchoServer's myOnMsg callback gets invoked when you send a message from a websocket client. However, the EchoServer's onMessage callback does not. Though onOpen and onClose of EchoServer get invoked normally.
Randomly I seem to get following error
ERROR [2023-09-07 08:38:58,147] com.myProject.websockets.LiveWebsocketResource: websocket error: Cannot call method public void com.myProject.websockets.LiveWebsocketResource#onMsg(java.lang.Object, java.lang.String) with args: [org.eclips
e.jetty.websocket.jsr356.JsrSession, java.lang.String]
ERROR [2023-09-07 08:41:00,371] org.hibernate.engine.jdbc.spi.SqlExceptionHelper: (conn=2269) Lock wait timeout exceeded; try restarting transaction
ERROR [2023-09-07 08:41:00,375] io.dropwizard.jersey.errors.LoggingExceptionMapper: Error handling a request: 6324d703a0d6b8fa
I can't reproduce locally though. Even if onMsg
is accepting only javax.websocket.Session
it occurs.
This error seems to lock some of my DB tables.
Maybe this is related to me using dropwizard2.1
In the docs you show an alternative to your project is:
https://github.com/TomCools/dropwizard-websocket-jee7-bundle
What's the difference?
Are there any plans to upgrade this to be compatible with the 1.0.0 build of dropwizard?
Heya,
Great project, and I'd love to use it. But VersionEye shows that a lot of dependencies are out of date, and one includes a security vulnerability: https://www.versioneye.com/user/projects/5642ede8c5999a0009027e23
Would it be possible to update the project to latest versions & push it to maven? Should be a simple change, and then I'd love to use this.
Thanks.
Even after quite a bit of searching, it's not at all clear to me how one could hook in authentication based on the original HTTP request (eg, based on session or headers).
It would be nice if the endpoint classes could be registered in the application run() method, instead of having to be provided during initialize().
Among other advantages, this would allow them to be optional based on the configuration.
Hi,
I am trying to have a dependency injected into the server end point but it's not working, I understand that the bundle and the endpoint are not going through the dependency injection cycle. Is it possible to inject objects without adding them to the user properties config, that's the work around I am using right now.
Thanks for your help.
Dropwizard 1.3.0
Dropwizard-websockets 1.3.2
In the docs it shows the possibility to create a Websocket bundle object in the Dropwizard Application class as a property.
Then in the run()
and initialize()
stages you can add Websocket endpoints.
However the WebsocketBundle class does not have a zero arg constructor. To hack it and make it work you have to provide a Websocket class.
This is not ideal if you are wanting to programmatically control the websocket instance. Therefore a DummyWebsocket
was used as an argument, and is ignored by the application, like so.
public class ServiceApplication extends Application {
private WebsocketBundle websocketBundle;
public static void main(final String[] args) throws Exception {
new ServiceApplication().run(args);
}
@Override
public void initialize(final Bootstrap<ServiceConfiguration> bootstrap) {
websocketBundle = new WebsocketBundle(DummyWebsocket.class);
bootstrap.addBundle(websocketBundle);
}
@Override
public void run(final ServiceConfiguration config,
final Environment environment) {
//websocket - queue handler
final ServerEndpointConfig wsConfig = BasicServerEndpointConfig.Builder.create(WebsocketQueueHandler.class, "/websocket").build();
websocketBundle.addEndpoint(wsConfig);
}
Can we have support to create a WebsocketBundle instance without any constructor arguments?
Thanks
I tried to setup a project with drop-wizard 1.1.0 (also 1.1.2), but the server do no starts because of this error:
org.eclipse.jetty.websocket.api.extensions.Extension: Provider org.eclipse.jetty.websocket.common.extensions.compress.DeflateFrameExtension could not be instantiated
Can you provide some suggestion. I tried all the ways that was suggested in the documentation.
Thanks!
Hi!
It is possible use the default io.dropwizard.auth
with dropwizard-websockets
?
In our project we are using OAuth authenticantion in resources.
I'm testing this class
@Timed(name = "timed")
@Metered(name = "metered")
@ExceptionMetered(name = "exception")
@ServerEndpoint("/socket")
@PermitAll
public class NotificationSocket {
@OnOpen
public void myOnOpen(final Session session) throws IOException {
System.out.println("Principal: " + session.getUserPrincipal());
session.getAsyncRemote().sendText("welcome");
}
@OnMessage
public void myOnMsg(final Session session, String message) {
session.getAsyncRemote().sendText(message);
}
@OnClose
public void myOnClose(final Session session, CloseReason cr) {
}
}
with this simple node script:
var WebSocket = require('ws')
const options = {
headers: {
'Authorization': 'Bearer token' // token is a system generated string
}
}
const ws = new WebSocket('ws://localhost:58040/socket', options)
ws.on('message', function incoming(data) {
console.log(data);
})
and the Principal always is null
.
I want to associate each session ith the logged user.
Thanks!
Thanks for this project. It's sorely needed. However, it looks like the dependencies are out of date when you try to use this project w/ Dropwizard 1.2.2. There was another issue made about this, it looks like that person figured it out, but I wasn't able to: #16
Can you please look into the dependencies and get the project building w/ dropwizard 1.2.2?
I'm trying to figure out the best way of accessing singleton services in from a websocket endpoint class without resorting to static fields/methods. I was expecting to be able to use @Inject since it's managed by jersey but it's not working.
I've thrown together an example project using @Inject on both a regular Dropwizard resource and a websocket endpoint, see https://github.com/mpbarnwell/dropwizard-websockets-test
As expected, using curl against the Dropwizard resource returns the service's hash code:
curl -X GET http://localhost:8080/test
1979257230
But running against the webservice endpoint produces a NPE.
curl 'http://localhost:8080/ws' -H 'Sec-WebSocket-Version: 13' -H 'Sec-WebSocket-Key: Yx2RoE1qwByK+r3fO25+/Q==' -H 'Upgrade: websocket' -H 'Connection: Upgrade'
��NullPointerException
Dropwizard 2.0.34 upgraded to jetty v9.4.49.v20220914. Jetty 9.4.49 made a backwards breaking change, jetty/jetty.project#8628, that makes it incompatible with websocket-server
9.4.18.v20190429
.
Suggest upgrading this package to the latest Jetty websocket-server
.
Hi,
We recently have upgrade one of our product from Jetty 6.1.2 to jetty 9.4.12. Post to upgrade, we landed up in an issue where session is being invalidated for subsequent requests. We are using embedded Jetty here. I have configured the DefaultSessionCache and NullSessionDataStore to persist sessions in-memory. I also have set cookie-config flags i.e "http-only" and "secure" as false also, to check in case it works with that. But still the same issue where we can see stale connections error is being logged in the logs.
Please help with your expert recommendations on what am I missing here to configure.
Regards...!
I have added the dependency to my maven project as specified and overrides initialize as:
@Override public void initialize(Bootstrap<AppConfiguration> bootstrap) { //attaches the WebSocket endpoint bootstrap.addBundle(new WebsocketBundle(WebSocketEndpoint.class)); }
When I run the application without the WebSocket endpoint it works fine but when I uncomment bootstrap.addBundle(new WebsocketBundle(WebSocketEndpoint.class));
I keep getting this error:
org.eclipse.jetty.websocket.api.extensions.Extension: Provider org.eclipse.jetty.websocket.common.extensions.compress.DeflateFrameExtension could not be instantiated
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.