# Shotgun: missing transition for gun\_down

**URL:** <https://erlangforums.com/t/shotgun-missing-transition-for-gun-down/4032>\
**Category:** Questions / Help\
**Tags:** erlang, shotgun\
**Created:** [September 27, 2024, 8:48am UTC](https://erlangforums.com/t/shotgun-missing-transition-for-gun-down/4032 "2024-09-27T08:48:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![acema](https://erlangforums.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@acema](https://erlangforums.com/u/acema)\
**Post date:** [September 27, 2024, 8:48am UTC](https://erlangforums.com/t/shotgun-missing-transition-for-gun-down/4032/1 "2024-09-27T08:48:22Z")

</div>

I am sending several POST requests to InfluxDB with `shotgun`. I reuse an existing connection. After some time the server decides to close the connection although I use a keep-alive in the header.

In my case `shutgun` fails because of a missing transistion in `gen_statem` from state `at_rest`. This state can’t handle a `gun_down` event. But I still think the problem is on my side! Please give me hint what I am doing wrong.

Crash Log:

```erlang
2024-09-27 08:25:22 =ERROR REPORT====
** State machine <0.3080.0> terminating
** Last event = {info,{gun_down,<0.3081.0>,http,closed,[]}}
** When server state = {at_rest,#{async => false,data => <<>>,pid => <0.3081.0>,stream => #Ref<0.3941012180.4012638211.1733>,buffer => <<>>,handle_event => undefined,headers => undefined,from => {<0.3020.0>,#Ref<0.3941012180.4012638209.195735>},status_code => undefined,async_mode => binary,responses => {[],[]},pending_requests => {[],[]}}}
** Reason for termination = error:function_clause
** Callback modules = [shotgun]
** Callback mode = state_functions
** Stacktrace =
** [{shotgun,at_rest,[cast,{gun_down,<0.3081.0>,http,closed,[]},#{async => false,data => <<>>,pid => <0.3081.0>,stream => #Ref<0.3941012180.4012638211.1733>,buffer => <<>>,handle_event => undefined,headers => undefined,from => {<0.3020.0>,#Ref<0.3941012180.4012638209.195735>},status_code => undefined,async_mode => binary,responses => {[],[]},pending_requests => {[],[]}}],[{file,"/home/fk/repos/png/alm_tooling/alm-metrics/_build/default/lib/shotgun/src/shotgun.erl"},{line,438}]},{gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,3113}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,329}]}]
2024-09-27 08:25:22 =CRASH REPORT====
  crasher:
    initial call: shotgun:init/1
    pid: <0.3080.0>
    registered_name: []
    process_label: undefined
    exception error: {function_clause,[{shotgun,at_rest,[cast,{gun_down,<0.3081.0>,http,closed,[]},#{async => false,data => <<>>,pid => <0.3081.0>,stream => #Ref<0.3941012180.4012638211.1733>,buffer => <<>>,handle_event => undefined,headers => undefined,from => {<0.3020.0>,#Ref<0.3941012180.4012638209.195735>},status_code => undefined,async_mode => binary,responses => {[],[]},pending_requests => {[],[]}}],[{file,"/home/fk/repos/png/alm_tooling/alm-metrics/_build/default/lib/shotgun/src/shotgun.erl"},{line,438}]},{gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,3113}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,329}]}]}
    ancestors: [shotgun_sup,<0.968.0>]
    message_queue_len: 0
    messages: []
    links: [<0.969.0>]
    dictionary: []
    trap_exit: false
    status: running
    heap_size: 1598
    stack_size: 29
    reductions: 911
  neighbours:
2024-09-27 08:25:22 =SUPERVISOR REPORT====
     Supervisor: {local,shotgun_sup}
     Context: child_terminated
     Reason: {function_clause,[{shotgun,at_rest,[cast,{gun_down,<0.3081.0>,http,closed,[]},#{async => false,data => <<>>,pid => <0.3081.0>,stream => #Ref<0.3941012180.4012638211.1733>,buffer => <<>>,handle_event => undefined,headers => undefined,from=> {<0.3020.0>,#Ref<0.3941012180.4012638209.195735>},status_code => undefined,async_mode => binary,responses => {[],[]},pending_requests => {[],[]}}],[{file,"/home/fk/repos/png/alm_tooling/alm-metrics/_build/default/lib/shotgun/src/shotgun.erl"},{line,438}]},{gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,3113}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,329}]}]}
     Offender: [{pid,<0.3080.0>},{id,shotgun},{mfargs,{shotgun,start_link,undefined}},{restart_type,temporary},{significant,false},{shutdown,5000},{child_type,worker}]

```

---

<div class="post-metadata">

**Author:** ![elbrujohalcon](https://erlangforums.com/user_avatar/erlangforums.com/elbrujohalcon/32/241_2.png) [@elbrujohalcon](https://erlangforums.com/u/elbrujohalcon)\
**Post date:** [September 27, 2024, 12:08pm UTC](https://erlangforums.com/t/shotgun-missing-transition-for-gun-down/4032/2 "2024-09-27T12:08:48Z")

</div>

This is very likely a `shotgun` bug, please report it as such on [https://github.com/inaka/shotgun/issues](https://github.com/inaka/shotgun/issues).  
But, to be fair and straightforward, that library has been a bit lacking in terms of support and maintainance for a few years already. So, if you (or someone) wants to help maintaining the library… I would be glad to give you permissions on the repository and hex.pm 🙂

---

<div class="post-metadata">

**Author:** ![acema](https://erlangforums.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@acema](https://erlangforums.com/u/acema)\
**Post date:** [September 27, 2024, 12:39pm UTC](https://erlangforums.com/t/shotgun-missing-transition-for-gun-down/4032/3 "2024-09-27T12:39:30Z")

</div>

My hopes were that it’s about my incapability to understand this excellent part of software. Most times I can fix my stuff. I’ll try to do the same with a fork of shotgun. If it works I’ll provide a PR.

Maybe in some time in future I can support to maintain shotgun. It would be an honor!

---

<div class="post-metadata">

**Author:** ![acema](https://erlangforums.com/letter_avatar_proxy/v4/letter/a/cc9497/32.png) [@acema](https://erlangforums.com/u/acema)\
**Post date:** [October 24, 2024, 6:51am UTC](https://erlangforums.com/t/shotgun-missing-transition-for-gun-down/4032/4 "2024-10-24T06:51:02Z")

</div>

Fixed in version 1.1.0.
