asyncmind on Nostr: Why does this not work #nostr does not support ws_upgrade ? test() -> {ok, ConnPid} = ...
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 03:47:59Event JSON
{
"id": "b23ec24be19d93a92f5d7afb8b28f945b09b1e98b1e04089ac562157bae7fd36",
"pubkey": "16d114303d8203115918ca34a220e925c022c09168175a5ace5e9f3b61640947",
"created_at": 1726804079,
"kind": 1,
"tags": [
[
"t",
"nostr"
]
],
"content": "Why does this not work #nostr does not support ws_upgrade ?\n\n\ntest() -\u003e\n {ok, ConnPid} =\n gun:open(\n \"relay.nostrdice.com\",\n 443\n ),\n {ok, _} = gun:await_up(ConnPid),\n StreamRef = gun:ws_upgrade(ConnPid, \"/\"),\n ?LOG_INFO(\"Started damage nostr\", []),\n\n receive\n {gun_upgrade, ConnPid, StreamRef, [\u003c\u003c\"websocket\"\u003e\u003e], []} -\u003e\n SubscriptionMessage = jsx:encode([\u003c\u003c\"REQ\"\u003e\u003e, \u003c\u003c\"damagebdd\"\u003e\u003e, #{}]),\n ?LOG_INFO(\"Nostr Sending message: ~p\", [SubscriptionMessage]),\n ok =\n gun:ws_send(\n ConnPid,\n StreamRef,\n {text, SubscriptionMessage}\n ),\n gun:flush(ConnPid);\n {gun_response, ConnPid, _, _, Status, Headers} -\u003e\n exit({ws_upgrade_failed, Status, Headers});\n {gun_error, ConnPid, StreamRef, Reason} -\u003e\n exit({ws_upgrade_failed, Reason})\n %% More clauses here as needed.\nafter 10000 -\u003e\n exit(timeout)\nend.\n",
"sig": "06f1685a7882b002bea0884ed75207be0c022206584526f7c433474d43dd83766041d48f2f453497d5b4be255708ca6dcb961cabe08deb0080f73628cb925c2c"
}