Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

function not exported {gun_http,ws_send,6} #320

Open
loudferret opened this issue Oct 23, 2023 · 4 comments
Open

function not exported {gun_http,ws_send,6} #320

loudferret opened this issue Oct 23, 2023 · 4 comments
Milestone

Comments

@loudferret
Copy link

Hello,
I've got into problems with gun, getting error during WebSocket communication:

05:02:57.569 [error] (<0.6553.0>) gen_statem <0.6553.0> in state connected terminated with reason: {{'function not exported',{gun_http,ws_send,6}},state_functions}
05:02:57.571 [error] (<0.6553.0>) gun_http:ws_send() CRASH REPORT Process <0.6553.0> with 0 neighbours crashed with reason: call to undefined function gun_http:ws_send({text,<<68,73,83,67,79,78,78,69,67,84,10,114,101,99,101,105,112,116,58,49,54,57,56,48,51,55,10,...>>}, {http_state,{sslsocket,{gen_tcp,#Port<0.427>,tls_connection,undefined},[<0.7039.0>,<0.7038.0>]},...}, #Ref<0.677379504.1938030593.128067>, <0.6552.0>, gun_default_event_h, undefined)
05:02:57.571 [error] (<0.408.0>) gun_http:ws_send() Supervisor gun_conns_sup had child gun started with {gun,start_link,undefined} at <0.6553.0> exit with reason call to undefined function gun_http:ws_send({text,<<68,73,83,67,79,78,78,69,67,84,10,114,101,99,101,105,112,116,58,49,54,57,56,48,51,55,10,...>>}, {http_state,{sslsocket,{gen_tcp,#Port<0.427>,tls_connection,undefined},[<0.7039.0>,<0.7038.0>]},...}, #Ref<0.677379504.1938030593.128067>, <0.6552.0>, gun_default_event_h, undefined) in context child_terminated

crash.log:

2023-10-23 07:02:37 =ERROR REPORT====
** State machine <0.7478.0> terminating
** Last event = {cast,{ws_send,<0.7477.0>,#Ref<0.909301808.2701131777.67881>,{text,<<68,73,83,67,79,78,78,69,67,84,10,114,101,99,101,105,112,116,58,49,54,57,56,48,52,53,10,10,0,10>>}}}
** When server state  = {connected,{state,<0.7477.0>,{up,#Ref<0.909301808.2701131777.67863>},"websocket-server-fqdn-address",443,<<"https">>,"websocket-server-fqdn-address",443,[],#{retry => 10,retry_timeout => 10000,transport => tls},undefined,{sslsocket,{gen_tcp,#Port<0.462>,tls_connection,undefined},[<0.7749.0>,<0.7748.0>]},gun_tls,true,{ssl,ssl_closed,ssl_error},gun_http,{http_state,{sslsocket,{gen_tcp,#Port<0.462>,tls_connection,undefined},[<0.7749.0>,<0.7748.0>]},gun_tls,#{},'HTTP/1.1',keepalive,<<>>,undefined,[],head,{0,0},head},undefined,gun_default_event_h,undefined}}
** Reason for termination = error:{'function not exported',{gun_http,ws_send,6}}
** Callback modules = [gun]
** Callback mode = state_functions
** Stacktrace =
**  [{gun,connected,3,[{file,"/home/.../_build/default/lib/gun/src/gun.erl"},{line,1335}]},{gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,1426}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]
2023-10-23 07:02:37 =CRASH REPORT====
  crasher:
    initial call: gun:init/1
    pid: <0.7478.0>
    registered_name: []
    exception error: {undef,[{gun_http,ws_send,[{text,<<68,73,83,67,79,78,78,69,67,84,10,114,101,99,101,105,112,116,58,49,54,57,56,48,52,53,10,10,0,10>>},{http_state,{sslsocket,{gen_tcp,#Port<0.462>,tls_connection,undefined},[<0.7749.0>,<0.7748.0>]},gun_tls,#{},'HTTP/1.1',keepalive,<<>>,undefined,[],head,{0,0},head},#Ref<0.909301808.2701131777.67881>,<0.7477.0>,gun_default_event_h,undefined],[]},{gun,connected,3,[{file,"/home/.../_build/default/lib/gun/src/gun.erl"},{line,1335}]},{gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,1426}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}
    ancestors: [gun_conns_sup,gun_sup,<0.406.0>]
    message_queue_len: 1
    messages: [{'DOWN',#Ref<0.909301808.2701131777.67863>,process,<0.7477.0>,{shutdown,game_over}}]
    links: [<0.408.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 2586
    stack_size: 28
    reductions: 40211
  neighbours:
2023-10-23 07:02:37 =SUPERVISOR REPORT====
     Supervisor: {local,gun_conns_sup}
     Context:    child_terminated
     Reason:     {undef,[{gun_http,ws_send,[{text,<<68,73,83,67,79,78,78,69,67,84,10,114,101,99,101,105,112,116,58,49,54,57,56,48,52,53,10,10,0,10>>},{http_state,{sslsocket,{gen_tcp,#Port<0.462>,tls_connection,undefined},[<0.7749.0>,<0.7748.0>]},gun_tls,#{},'HTTP/1.1',keepalive,<<>>,undefined,[],head,{0,0},head},#Ref<0.909301808.2701131777.67881>,<0.7477.0>,gun_default_event_h,undefined],[]},{gun,connected,3,[{file,"/home/.../_build/default/lib/gun/src/gun.erl"},{line,1335}]},{gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,1426}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]}
     Offender:   [{pid,<0.7478.0>},{id,gun},{mfargs,{gun,start_link,undefined}},{restart_type,temporary},{significant,false},{shutdown,5000},{child_type,worker}]

I hope this can identify the problem.


I do use last (hex.pm) version of gun, dependency defined in rebar.config

{gun, "2.0.1"}

on Debian Bookworm, Erlang version 1:25.2.3+dfsg-1

@essen
Copy link
Member

essen commented Oct 23, 2023

Can you post the code to reproduce? It looks like you are trying to call ws_send when you're still over HTTP, either the upgrade has not succeeded/completed or you haven't done the upgrade.

@loudferret
Copy link
Author

Hi essen,
you're probalbly right. It seems the process received gun_down and gun_up and did not upgrade to WS afterwards. I'll investigate further and will let you know in case I discover anything else.

You can close the issue (from my point of view), sorry for bothering.

@essen
Copy link
Member

essen commented Oct 24, 2023

The crash is not something nice to have it should error out instead. I think I got some todos but having the issue open is a good reminder for an eventual fix. Thanks for the report!

@dudalev
Copy link

dudalev commented Oct 22, 2024

also hit this problem when the remote server started replying unexpectedly - i trtied to reconnect too many times and got rate-limited by the server, causing it to force disconnection when/after sending a message or something like that

@essen essen added this to the 2.2.0 milestone Jan 15, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants