derGigi โก๐งก 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:50Event JSON
{
"id": "cf56639310621593bec74a632385c7dd032b1ac8587d91cafff292583ff0f676",
"pubkey": "520fc1e8c66439a6a77799dc33d6158808d2e8d215cf329a3c7dc245af62cb3c",
"created_at": 1726857470,
"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": "c2d8e3db66e6d61b68d1d1b92702f2fd8a78c76222dffcc40df722d16e2de1a172c4efc6b226c993a5864c02ba31b441481f3eac80e9b6dedc843866b3dfffec"
}