tcheeric / nostr-java

A nostr library, written in java, for generating, signing and publishing events.
MIT License
68 stars 22 forks source link

Replace jetty with jdk's native libraries for http and websocket connections to support Android #120

Closed kuiperanon closed 4 months ago

kuiperanon commented 6 months ago

Created this issue based on this conversation: note17whh90a4wfy09f4ru4cp5uulfv39f55t74atauw6u89k5nt0cecqqku3wz

I don't think the library can be used on android for the above reasons, and to make it work, I would have to ditch jetty, and use the jdk's native libraries for http and websocket connections. This would be a non trivial change that would take time to develop, but I'll look more into it.

Here is the stack trace: https://gist.github.com/kuiperanon/27dee382b927108e894fddb6a3008691#file-android-nostr-java-stacktrace-txt

tcheeric commented 6 months ago

Possibly a big change. This will go in the next iteration.

kuiperanon commented 6 months ago

ATM I'm experimenting with java.net.URLConnection and getting that to work in a few places.

tcheeric commented 5 months ago

I have removed jetty for websocket support, and now only use the native jdk. I can successfully send messages to the relays, but the problem I am currently facing is that I am not receiving the messages back from the relays (notice, eose, ok etc)

I found this solution on reddit, and made the change in nostr.connection.impl.ConnectionPool.connect() but it's still not working for me. I need to do more research. https://www.reddit.com/r/learnjava/comments/b65sar/require_assistance_with_simple_pure_java_11/?rdt=47773

Here is the branch: https://github.com/tcheeric/nostr-java/tree/feature/0.6-SNAPSHOT

PS: You will notice that I have made significant changes to the structure. I hope this will be more intuitive and maintainable.

avlo commented 4 months ago

Hi, @tcheeric. Related to your comments above- If you (and/or others) are interested or find the following useful, I've built a spring-boot nostr-relay implementation leveraging the nostr-java API & several other nostr-java libraries.

The relay connection mechanism uses springframework websocket/websocketsession, backed by a canonical spring-boot MVC webapp framework.

The relay currently handles websocket event types:

and current nostr message types:

with specific handlers so far for nostr kinds:

The relay handles client/server event requests as expected, with session management and a db store as well.

Development is actively ongoing with detailed information/"how-to" document on the master branch README.

Your/anyone's interest for use and/or collaborative/ongoing development is welcome.

tcheeric commented 4 months ago

Hi @avlo,  Very nice. I'll definitely have a closer look tonight. Just a quick remark, you may have noticed that we're currently working on the develop branch, and the next release will introduce major changes, for example, we're moving away from configuration files for relays, identities. This information is now supplied "on the fly"...

-- Sent with Tuta; enjoy secure & ad-free emails: https://tuta.com

26 Apr 2024, 23:18 by @.***:

Hi, > @tcheeric https://github.com/tcheeric> . Related to your comments above- If you (and/or others) are interested or find the following useful, I've built a > spring-boot nostr-relay implementation https://github.com/avlo/nostr-relay> leveraging the nostr-java API & several other nostr-java libraries.

The relay connection mechanism uses springframework websocket/websocketsession, backed by a canonical spring-boot MVC webapp framework.

The relay currently handles websocket event types:

ONOPEN ONCLOSE ONMESSAGE

and current nostr message types:

EVENT REQ

with specific handlers so far for nostr kinds:

NIP01 (TextNotEvent) NIP99 (ClassifiedListingEvent)

The relay handles client/server event requests as expected, with session management and a db store as well.

Development is actively ongoing with detailed information/"how-to" document on the master branch > README https://github.com/avlo/nostr-relay> .

Your/anyone's interest for use and/or collaborative/ongoing development is welcome.

— Reply to this email directly, > view it on GitHub https://github.com/tcheeric/nostr-java/issues/120#issuecomment-2080185150> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/ABQMG7AED67RQ2EA2LDI3D3Y7LHBVAVCNFSM6AAAAABFH4QBTKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBQGE4DKMJVGA> . You are receiving this because you were mentioned.> Message ID: > <tcheeric/nostr-java/issues/120/2080185150> @> github> .> com>

avlo commented 4 months ago

@tcheeric, thanks for the heads up and yes- nostr-relay master branch (0.0.1-SNAPSHOT) uses nostr-java develop branch (0.6-SNAPSHOT) without dependency on any nostr-java relay/identity configurations.

in other words- in alignment with your strategy, nostr-relay configuration is self contained.

tcheeric commented 4 months ago

@avlo - I notice that you have extended nostr-event with additional events/tags. Can you please submit a PR to me when you have a chance, so that I can include it in my code as well? Thanks.

avlo commented 4 months ago

@tcheeric, sure- will do. booked at the moment but should be submitted by tomorrow (sun) night.