Closed gourcetools closed 1 year ago
It seems that the wss://relay.realsearch.cc relay doesn't conform to the
output standard of other relay implementations. It's possible to add
support for pretty JSON output, however relay's JSON output should be
compressed and with all the \n
, as it's just extra data.
The logic is a little basic in nostrcat
right now, as I could parse the
JSON to a struct, however the new lines will still break most JSON parsers.
For example this will error with new lines, but works without them. If you
want pretty json output, I suggest you use the jq
on the command line,
which will add new lines and spacing - however over the wire,
compressed/compacted JSON is required.
let input = r#"\n["EOSE","ede73d9a-e332-4e06-b62f-acede3383cbd"]"#;
println!("{:?}",
serde_json::from_str::<serde_json::Value>(&input).unwrap());
// This errors. It's fine with the \n removed
impl Response {
pub fn from_string(s: String) -> Self {
match s {
s if s.starts_with(r#"["EVENT""#) => Response::Event(s),
s if s.starts_with(r#"["NOTICE""#) => Response::Notice(s),
s if s.starts_with(r#"["OK""#) => Response::Ok(s),
s if s.starts_with(r#"["EOSE""#) => Response::EOSE(s),
_ => Response::Unsupported(s),
}
}
}
Are you the author of the relay implementation, or just a relay operator?
curl -i -N -H "Connection: Upgrade" -H "Accept: application/nostr+json"
https://relay.realsearch.cc
HTTP/1.1 200 OK
Server: nginx/1.14.1
Date: Fri, 06 Jan 2023 10:07:48 GMT
Content-Type: application/json; charset=utf-8
Content-Length: 329
Connection: keep-alive
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET, POST, PUT, OPTIONS
Access-Control-Allow-Headers: accept,content-type,x-requested-with
{
"name":"Realsearch Nostr Relay",
"description":"This is a fast relay with full archive of textual posts",
"pubkey":"3356de61b39647931ce8b2140b2bab837e0810c0ef515bbe92de0248040b8bdd",
***@***.***",
"supported_nips":[
1,
11,
12,
15,
20,
22
],
"software":"https://relay.realsearch.cc",
"version":"0.1"
}
Hey, thank you for the explainations. Im very bad at programation but im writing a shell script that use nostcat to convet events to Gource log file. My horrible code can be found at github.com/gourcetools/nostr2gource For now i just removed this relay from relays.txt . Thank you for the time you took to explain and the solution provided, i did not expect that much.
You're welcome. Let me know when you get a visualisation of Nostr. I'm sure everyone on Nostr will love it.
When downloading events from wss://relay.realsearch.cc i get this error:
Received unsupported nostr data: "\n[\n\"EVENT\",\n\"RAND\",\n{\n\"id\":\"f9cb12c2e433b29a7441f897204804b83a5b9b7fdd903a759927029f17feac4e\",\n\"pubkey\":\"e022f5138944612a5cdbdaf13591fcf85c881f6616b8527eb24175aaca2c0aa0\",\n\"created_at\":1672993199,\n\"kind\":1,\n\"tags\":[\n[\n\"client\",\n\"astral\"\n]\n],\n\"content\":\"@5e7ae588d7d11eac4c25906e6da807e68c6498f49a38e4692be5a089616ceb18 Verifying My Public Key: \\\"highfar888\\\"\",\n\"sig\":\"621eba3ac2f6dc793c53a227a0553b83fca5355c8cc37546bbda87c983784af6e5ba6494639dd1612533e62b40249143852b061d225bc6a838d3a4823cf8323a\"\n}\n]"