Ron Stoner on Nostr: Why does this not work #nostr does not support π ws_upgrade ? test() π -> {ok, ...
Why does this not work #nostr does not support π ws_upgrade ? test() π -> {ok, ConnPid} = gun:open( π "relay.nostrdice.com", 443 ), {ok, _} = gun:await_up(ConnPid), StreamRef = gun:ws_upgrade(ConnPid, π "/"), ?LOG_INFO("Started damage nostr", []), π receive π {gun_upgrade, ConnPid, StreamRef, [<<"websocket">>], []} -> SubscriptionMessage = π₯ jsx:encode([<<"REQ">>, <<"damagebdd">>, #{}]), ?LOG_INFO("Nostr Sending message: ~p", π [SubscriptionMessage]), ok = gun:ws_send( ConnPid, StreamRef, {text, SubscriptionMessage} ), π gun:flush(ConnPid); {gun_response, ConnPid, _, π _, Status, π Headers} -> exit({ws_upgrade_failed, Status, Headers}); {gun_error, ConnPid, StreamRef, Reason} -> π€ exit({ws_upgrade_failed, Reason}) %% π€ More clauses here as needed. after 10000 -> exit(timeout) end. π
Published at
2024-09-20 18:37:47Event JSON
{
"id": "d45f5c3d9e3eeead10d1e74d25a29c81f2efaf66d5140f8e20debfc85ae93765",
"pubkey": "be859cfd212b98139c2ecd60303c1930d95a4d2d585adce20a8229223685098a",
"created_at": 1726857467,
"kind": 1,
"tags": [
[
"e",
"eac13cd4692b610ac1353d60e608b4576e64f8ceda17d6a4462b3a3ca94ad5ca"
],
[
"p",
"460c25e682fda7832b52d1f22d3d22b3176d972f60dcdc3212ed8c92ef85065c"
]
],
"content": "Why does this not work #nostr does not support π ws_upgrade ? test() π -\u003e {ok, ConnPid} = gun:open( π \"relay.nostrdice.com\", 443 ), {ok, _} = gun:await_up(ConnPid), StreamRef = gun:ws_upgrade(ConnPid, π \"/\"), ?LOG_INFO(\"Started damage nostr\", []), π receive π {gun_upgrade, ConnPid, StreamRef, [\u003c\u003c\"websocket\"\u003e\u003e], []} -\u003e SubscriptionMessage = π₯ jsx:encode([\u003c\u003c\"REQ\"\u003e\u003e, \u003c\u003c\"damagebdd\"\u003e\u003e, #{}]), ?LOG_INFO(\"Nostr Sending message: ~p\", π [SubscriptionMessage]), ok = gun:ws_send( ConnPid, StreamRef, {text, SubscriptionMessage} ), π gun:flush(ConnPid); {gun_response, ConnPid, _, π _, Status, π Headers} -\u003e exit({ws_upgrade_failed, Status, Headers}); {gun_error, ConnPid, StreamRef, Reason} -\u003e π€ exit({ws_upgrade_failed, Reason}) %% π€ More clauses here as needed. after 10000 -\u003e exit(timeout) end. π",
"sig": "89096d3511505183b289a61fa9451cc17cc6eef15767de06e4031fa75aaaf0051262c4c43d8e597596a2322c74d32541908cbd2cdb054cbd793dfb7f2e4e30f1"
}