Why Nostr? What is Njump?
2024-09-20 03:47:59

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.
Author Public Key
npub1zmg3gvpasgp3zkgceg62yg8fyhqz9sy3dqt45kkwt60nkctyp9rs9wyppc