ninenines / gun

HTTP/1.1, HTTP/2, Websocket client (and more) for Erlang/OTP.
ISC License
891 stars 232 forks source link

** Reason for termination = error:{'function not exported', {string,lowercase,1}} #262

Closed jainygaurav closed 3 years ago

jainygaurav commented 3 years ago

Please help me with this issue.

While using https://github.com/inaka/apns4erl, I get following error:

{deps, [
  {gun, "2.0.0-rc.1"},
  {jsx, "3.0.0"},
  {base64url, "1.0.1"}
]}.

6> apns:push_notification(my_first_connection, DeviceId, Notification).

=ERROR REPORT==== 8-Mar-2021::03:28:04 ===
...
                                     gun_monitor => #Ref<0.0.1.190>,
                                     gun_pid => <0.91.0>}}
** Reason for termination = error:{'function not exported',
                                      {string,lowercase,1}}
** Callback mode = state_functions
** Stacktrace =
**  [{gun,normalize_headers,1,
          [{file,"/home/ubuntu/tyme-it-backend/apns4erl_v2_otp_19.3.6/_build/default/lib/gun/src/gun.erl"},
           {line,654}]},
     {gun,request,6,
          [{file,"/home/ubuntu/tyme-it-backend/apns4erl_v2_otp_19.3.6/_build/default/lib/gun/src/gun.erl"},
           {line,638}]},
     {apns_connection,push,5,
                      [{file,"/home/ubuntu/tyme-it-backend/apns4erl_v2_otp_19.3.6/src/apns_connection.erl"},
                       {line,475}]},
     {apns_connection,connected,3,
                      [{file,"/home/ubuntu/tyme-it-backend/apns4erl_v2_otp_19.3.6/src/apns_connection.erl"},
                       {line,312}]},
     {gen_statem,call_state_function,5,[{file,"gen_statem.erl"},{line,1223}]},
     {gen_statem,loop_event,6,[{file,"gen_statem.erl"},{line,995}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]
** exception exit: {undef,{gen_statem,call,
                                      [my_first_connection,
                                       {push_notification,<<"4c1f88da4e9c5ca23a6d186dad745b3b6817d9fd2ddea095fbfa667c0929d31d">>,
                                                          <<"{\"aps\":{\"alert\":\"you have a message\"}}">>,
                                                          #{apns_expiration => <<"0">>,apns_priority => <<"10">>,
                                                            apns_push_type => <<"alert">>,
                                                            apns_topic => <<"com.example.myapp">>}},
                                       infinity]}}
     in function  gen:do_call/4 (gen.erl, line 177)
     in call from gen_statem:call/3 (gen_statem.erl, line 449)
jainygaurav commented 3 years ago

Looks like string:lowercaseis OTP 20.0.

How can I make it work for OTP 19.3.6? Please help!

paulo-ferraz-oliveira commented 3 years ago

In this case, there's no easy workaround. You'll have to bump to OTP 20.0. Otherwise you can also take a poke at parse_transforms but it's overkill.

dariomalfatti-centropaghe commented 2 years ago

hi @jainygaurav, did you find a solution for this? I'm stack too with this error:

gen_statem 'apns_com.centropaghe.viavoip' in state connected terminated with reason: {'function not exported',{string,lowercase,1}} in gun:normalize_headers/1 line 661
CRASH REPORT Process 'apns_test' with 0 neighbours crashed with reason: call to undefined function string:lowercase(<<"apns-topic">>)

If I run erl in console, I got this output:

Erlang/OTP 22 [erts-10.7.2.1] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] [hipe]