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": "cf77ba1ee1a175911e5f4065d66f040baba646cce907a505a067182d145abcfe",
"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": "69df3600744a5d9c97b48a4e64ce793d4110a01fe13793b2d83e60d0f09822f5046f44723a34d88ed26ef1a2daaf73938cf47242a447cbfd7002bf1216885be5"
}