-
Notifications
You must be signed in to change notification settings - Fork 21
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
ServiceLoader is not instantiating the command handler classes #147
Comments
Ok, I will take a look and answer you soon. |
I'd like to simulate your problem here. How can I do this? What is the test that you are trying? What is the branch that I need to look? 0.6-SNAPSHOT ? About your points:
|
Branch is 0.6-SNAPSHOT When you receive a message from a relay (ok, eose, notice etc) we use the service locator to instantiate the corresponding command handler class (default or custom) and run its handle method. This doesn't work, the service locator doesn't find the handler classes. This is what I'm struggling with at the moment. It seems so obvious but I can't find where the problem is. Agree re. caution with module changes but I saw these modifications as necessary. For clients, this would hopefully not be too much to change, just a bit of refactoring, changing their custom handlers, and create separate classes for each instead. Thanks. |
I found a problem with this change, the example of "filters" broke, it's not necessary to sign a request for search events, they are public. |
Well, I'm getting a problem when try to connect with relays. When happened any problem during the connection with relay, I get an error here and all connections with all relays stop and no event is sent.
I just add a try-catch to ignore this error and now the message "was sent". Actually failed again, but was another cause (the connection wasn't correctly established), the log messages are wrong.
|
Yes, correct. |
So, I will let you check this problem and fix it. You can test it with this example. |
About this problem, I observed that you instanced the listener in ConnectionImpl as an OpenListener, but how the WebSocket will know when call TextListener, CloseListener or whatever? It's not clear for me. I did a test and got success just changing OpenListener to TextListener. Log:
|
I observed either that the pool of connection is a little unstable. Maybe it was caused by the timeout, I don't know, but some times no connections are successfully established. We need to analyze carefully this pool and make sure it is under control. |
Alright, will do. |
I have found a solution. Look at how I now use the CompositeListener class to pass all listeners. A COUPLE OF THINGS that I forgot to mention:
NOW, with these issues solved, my original problem should become apparent: the ServiceLoader still does not instantiate the command handlers (ok, eose, auth etc.) |
I have finally found the issue with the ServiceLoader! |
@guilhermegps
While trying to implement NIP-42, I noticed some limitations with the current code.
NIP-42 expects the client to reply with a signed auth event when receiving an AUTH-message from a relay. Currently, this takes place in the onAuth method here.
However, to sign the event, you need to have access to the private key, which is not available in that class at the moment.
I have therefore introduced the concept of Context classes, where I store contextual information, including the private key. The context is created in the api module when instantiating a client object, passed along to the other modules, and is now available in the OnAuth command handler.
Additional major changes (Branch 0.6-SNAPSHOT):
I welcome your opinions and suggestions on this.
NOW, the Problem I am facing, is that the ServiceLoader is not instantiating the handler classes (See here).
I need a second pair of eyes to review and hopefully find what is missing, and why it's not working.
Could you please have a look when you have a moment?
Thanks!
The text was updated successfully, but these errors were encountered: