strfry icon indicating copy to clipboard operation
strfry copied to clipboard

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

Open Memory-of-Snow opened this issue 2 years ago • 2 comments

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.

Memory-of-Snow avatar Jun 07 '23 00:06 Memory-of-Snow

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.

hoytech avatar Jun 10 '23 04:06 hoytech

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.

Memory-of-Snow avatar Jun 10 '23 05:06 Memory-of-Snow