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

If a Japanese character is set as the subscriber ID and a REQ message is sent, relay will return "NOTICE". #42

Open
Memory-of-Snow opened this issue Jun 7, 2023 · 2 comments

Comments

@Memory-of-Snow
Copy link

Describe the bug
"If a Japanese character is set as the subscriber ID and a REQ message is sent from the client to the relay, it will return ["NOTICE","ERROR: bad req: invalid character in subscription id"]."

To Reproduce
For example, sending ["REQ", "日本語のサブスクライバーID", {"kinds": 1, "limit": 10}] from the client to the relay.

Expected behavior
It is possible to use Japanese characters(and other language too) as the subscriber ID.

Additional context
For <subscription_id>, the following rules are defined in NIP-01.
<subscription_id>”<subscription_id> is an arbitrary, non-empty string of max length 64 chars, that should be used to represent a subscription.”
The specification for characters is not provided.

@hoytech
Copy link
Owner

hoytech commented Jun 10, 2023

Hi, thanks for your report!

Currently strfry is quite restrictive on what you can use a subscription ID. I can make it work with your string, but can I ask why you want to do this?

In my opinion, the best format for a subscription ID is just an increasing integer. For example, on the first subscription of the connection, use "1". On the second, use "2", etc. The counter can be reset on each connection (subscription IDs are local to a single connection).

Note in your case you are using a sub ID of 38 bytes. Every event that is sent echos this entire string back to you. For example, if you received 1000 events, this would be 38000 bytes of bandwidth wasted.

@Memory-of-Snow
Copy link
Author

Thank you for your response.

Personally, I think it makes sense to use meaningful strings of characters for subscription IDs. In that case, I thought it would be easier to understand if we could use strings from each language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants