:socket_closed_remotely

When I am trying to request an internal IP , I am getting socket closed remotely.though it loads in normal browser.

:httpc.request(“http://192.168.1.1:52869/gatedesc.xml”|>String.to_charlist)
{:error, :socket_closed_remotely}

while doing request with HTTpoison works . Iam on elixir 1.15.4-otp-26
erlang 26.0.2

1 Like

any help possible?

There’s unfortunately not a lot of information to go on here. The error you’re receiving can occur under various conditions.

However, since you are not having problems with hackney (HTTPoison is a wrapper around hackney), then there may be a default setting in httpc that is either on or off, and/or not adjusted such that it plays well with the server you’re trying to connect to and GET data from.

That said, and without more info, I’d be curious if you tried Erlang/OTP 26.0.1 if the problem went away. The reason I’m curious about this is 7 months ago there was a slight tweak in http_handler to fix up another bug, which may inadvertently presented with you this problem.

1 Like

elixir 1.14.4-otp-26
erlang 26.0.1
I tried with this versions , but its still the same

1 Like

You may want to start by looking at options that are set by default

httpc:get_options(all) in conjunction with looking at the defaults

If nothing catches your eye, you may also want to turn on debug and have a look at what’s going on :

>  httpc:set_options([{verbose, debug}]).
> httpc:request(...).

Or in elixir:

> :httpc.set_options([{:verbose, :debug}])
> :httpc.request(...)

Debug is going to give you a ton of info, so you may want to start with [{verbose, verbose}].

Also, if you share info from debug be sure to redact for sensitive information.

1 Like
                                                          {state,
                                                           {request,
                                                            #Ref<0.4045007903.1400635393.262082>,
                                                            <0.215.0>,0,http,
                                                            {"192.168.1.1",
                                                             52869},
                                                            "/gatedesc.xml",
                                                            [],get,
                                                            {http_request_h,
                                                             undefined,
                                                             "keep-alive",
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             "192.168.1.1:52869",
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,[],
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,"0",
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,
                                                             undefined,[]},
                                                            {[],[]},
                                                            {http_options,
                                                             "HTTP/1.1",
                                                             infinity,true,
                                                             {essl,[]},
                                                             undefined,false,
                                                             infinity,false},
                                                            <<"http://192.168.1.1:52869/gatedesc.xml">>,
                                                            [],none,[],
                                                            1693670539132,
                                                            undefined,
                                                            undefined,
                                                            undefined,false},
                                                           {session,
                                                            {{"192.168.1.1",
                                                              52869},
                                                             <0.221.0>},
                                                            false,http,
                                                            {remote_close,
                                                             #Port<0.7>},
                                                            ip_comm,1,
                                                            keep_alive,false},
                                                           {"HTTP/1.1",200,
                                                            "OK"},
                                                           {http_response_h,
                                                            undefined,"close",
                                                            "Thu, 01 Jan 1970 09:55:16 GMT",
                                                            undefined,
                                                            undefined,
                                                            "chunked",
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            "Linux, UPnP/1.0, Portable SDK for UPnP devices/1.6.22",
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            undefined,"-1",
                                                            undefined,
                                                            undefined,
                                                            undefined,
                                                            "text/xml",
                                                            undefined,
                                                            "Thu, 01 Jan 1970 09:51:56 GMT",
                                                            [{"x-user-agent",
                                                              "redsonic"}]},
                                                           undefined,
                                                           {http_chunk,
                                                            decode_size,
                                                            [<<>>,[],0,
                                                             {nolimit,
                                                              <<"<?xml version=\"1.0\"?>\n<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\n  <specVersion>\n    <major>1</major>\n    <minor>0</minor>\n  </specVersion>\n  <URLBase>http://192.168.1.1:52869</URLBase>\n  <device>\n    <deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>\n    <friendlyName>UPNP IGD</friendlyName>\n    <manufacturer>ZTE</manufacturer>\n    <manufacturerURL>http://www.zte.com</manufacturerURL>\n    <modelDescription>ZTE Broadband Home Gateway</modelDescription>\n    <modelName>F670LV9.0</modelName>\n    <modelNumber>V1.0</modelNumber>\n    <modelURL>http://www.zte.com</modelURL>\n    <UDN>uuid:11111111-1111-1234-e8b8-45111126787e</UDN>\n    <UPC></UPC>\n     <serialNumber>ZTASDJNASD3454</serialNumber>\n    <iconList>\n      <icon>\n        <mimetype>image/gif</mimetype>\n        <width>118</width>\n        <height>119</height>\n        <depth>8</depth>\n        <url>/ligd.gif</url>\n      </icon>\n    </iconList>\n    <serviceList>\n      <service>\n        <serviceType>urn:schemas-microsoft-com:service:OSInfo:1</serviceType>\n        <serviceId>urn:microsoft-com:serviceId:OSInfo1</serviceId>\n        <controlURL>/upnp/control/OSInfo1</controlURL>\n        <eventSubURL>/upnp/event/OSInfo1</eventSubURL>\n        <SCPDURL>/gateinfoSCPD.xml</SCPDURL>\n      </service>\n    </serviceList>\n    <deviceList>\n      <device>\n        <deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>\n        <friendlyName>UPNP IGD</friendlyName>\n        <manufacturer>ZTE</manufacturer>\n        <manufacturerURL>http://www.zte.com</manufacturerURL>\n        <modelDescription>WAN Device on Linux IGD</modelDescription>\n        <modelName>F670LV9.0</modelName>\n        <modelNumber>V1.0</modelNumber>\n        <modelURL>http://www.zte.com</modelURL>\n        <UDN>uuid:11111111-1111-1234-e8b8-45111126787e</UDN>\n        <UPC></UPC>\n        <serialNumber>ZTASDJNASD3454</serialNumber>\n        <serviceList>\n          <service>\n            <serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>\n            <serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>\n            <controlURL>/upnp/control/WANCommonIFC1</controlURL>\n            <eventSubURL>/upnp/control/WANCommonIFC1</eventSubURL>\n            <SCPDURL>/gateicfgSCPD.xml</SCPDURL>\n          </service>\n        </serviceList>\n        <deviceList>\n          <device>\n            <deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>\n            <friendlyName>UPNP IGD</friendlyName>\n            <manufacturer>ZTE</manufacturer>\n            <manufacturerURL>http://www.zte.com</manufacturerURL>\n            <modelDescription>WanConnectionDevice ZTE HGW</modelDescription>\n            <modelName>B879LV89.0</modelName>\n            <modelNumber>V1.0</modelNumber>\n            <modelURL>http://www.zte.com</modelURL>\n            <UDN>uuid:11111111-1111-1234-e8b8-45111126787e</UDN>\n            <UPC></UPC>\n            <serialNumber>ZTASDJNASD3454</serialNumber>\n            <serviceList>\n              <service>\n                <serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>\n                <serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>\n                <controlURL>/upnp/control/WANIPConn1</controlURL>\n                <eventSubURL>/upnp/control/WANIPConn1</eventSubURL>\n                <SCPDURL>/gateconnSCPD.xml</SCPDURL>\n              </service>\n              <service>\n                <serviceType>urn:schemas-upnp-org:service:WANIPv6FirewallControl:1</serviceType>\n                <serviceId>urn:upnp-org:serviceId:WANIPv6FwCtrl1</serviceId>\n                <controlURL>/upnp/control/WANIPv6FwCtrl1</controlURL>\n                <eventSubURL>/upnp/control/WANIPv6FwCtrl1</eventSubURL>\n                <SCPDURL>/gatev6fwctrlASDF.xml</SCPDURL>\n              </service>\n            </serviceList>\n          </device>\n        </deviceList>\n      </device>\n    </deviceList>\n    <presentationURL>http://192.168.1.1</presentationURL>\n  </device>\n</root>\n">>,
                                                              4003,nolimit}]},
                                                           {[],[]},
                                                           {[],[]},
                                                           new,[],nolimit,
                                                           nolimit,
                                                           {options,
                                                            {undefined,[]},
                                                            {undefined,[]},
                                                            0,2,5,120000,2,
                                                            disabled,debug,
                                                            inet,default,
                                                            default,[],
                                                            undefined},
                                                           {timers,[],
                                                            undefined},
                                                           httpc_manager,
                                                           inactive}}
(<0.221.0>) call httpc_handler:terminate(normal,{state,{request,#Ref<0.4045007903.1400635393.262082>,<0.215.0>,0,http,
                {"192.168.1.1",52869},
                "/gatedesc.xml",[],get,
                {http_request_h,undefined,"keep-alive",undefined,undefined,
                                undefined,undefined,undefined,undefined,
                                undefined,undefined,undefined,undefined,
                                undefined,undefined,undefined,undefined,
                                "192.168.1.1:52869",undefined,undefined,
                                undefined,undefined,undefined,undefined,
                                undefined,undefined,undefined,[],undefined,
                                undefined,undefined,undefined,"0",undefined,
                                undefined,undefined,undefined,undefined,
                                undefined,[]},
                {[],[]},
                {http_options,"HTTP/1.1",infinity,true,
                              {essl,[]},
                              undefined,false,infinity,false},
                <<"http://192.168.1.1:52869/gatedesc.xml">>,[],none,[],
                1693670539132,undefined,undefined,undefined,false},
       {session,{{"192.168.1.1",52869},<0.221.0>},
                false,http,
                {remote_close,#Port<0.7>},
                ip_comm,1,keep_alive,false},
       {"HTTP/1.1",200,"OK"},
       {http_response_h,undefined,"close","Thu, 01 Jan 1970 09:55:16 GMT",
                        undefined,undefined,"chunked",undefined,undefined,
                        undefined,undefined,undefined,undefined,undefined,
                        undefined,undefined,
                        "Linux, UPnP/1.0, Portable SDK for UPnP devices/1.6.22",
                        undefined,undefined,undefined,undefined,undefined,
                        "-1",undefined,undefined,undefined,"text/xml",
                        undefined,"Thu, 01 Jan 1970 09:51:56 GMT",
                        [{"x-user-agent","redsonic"}]},
       undefined,
       {http_chunk,decode_size,
                   [<<>>,[],0,
                    {nolimit,<<"<?xml version=\"1.0\"?>\n<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\n  <specVersion>\n    <major>1</major>\n    <minor>0</minor>\n  </specVersion>\n  <URLBase>http://192.168.1.1:52869</URLBase>\n  <device>\n    <deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>\n    <friendlyName>UPNP IGD</friendlyName>\n    <manufacturer>ZTE</manufacturer>\n    <manufacturerURL>http://www.zte.com</manufacturerURL>\n    <modelDescription>ZTE Broadband Home Gateway</modelDescription>\n    <modelName>F670LV9.0</modelName>\n    <modelNumber>V1.0</modelNumber>\n    <modelURL>http://www.zte.com</modelURL>\n    <UDN>uuid:80902345-105a-1234-e8b8-1111111111a</UDN>\n    <UPC></UPC>\n    <serialNumber>ABCVQJMM2B00799</serialNumber>\n    <iconList>\n      <icon>\n        <mimetype>image/gif</mimetype>\n        <width>118</width>\n        <height>119</height>\n        <depth>8</depth>\n        <url>/ligd.gif</url>\n      </icon>\n    </iconList>\n    <serviceList>\n      <service>\n        <serviceType>urn:schemas-microsoft-com:service:OSInfo:1</serviceType>\n        <serviceId>urn:microsoft-com:serviceId:OSInfo1</serviceId>\n        <controlURL>/upnp/control/OSInfo1</controlURL>\n        <eventSubURL>/upnp/event/OSInfo1</eventSubURL>\n        <SCPDURL>/gateinfoSCPD.xml</SCPDURL>\n      </service>\n    </serviceList>\n    <deviceList>\n      <device>\n        <deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>\n        <friendlyName>UPNP IGD</friendlyName>\n        <manufacturer>ZTE</manufacturer>\n        <manufacturerURL>http://www.zte.com</manufacturerURL>\n        <modelDescription>WAN Device on Linux IGD</modelDescription>\n        <modelName>F670LV9.0</modelName>\n        <modelNumber>V1.0</modelNumber>\n        <modelURL>http://www.zte.com</modelURL>\n        <UDN>uuid:80902345-205a-1234-e8b8-1111111111a</UDN>\n        <UPC></UPC>\n        <serialNumber>ABCVQJMM2B00799</serialNumber>\n        <serviceList>\n          <service>\n            <serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>\n            <serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>\n            <controlURL>/upnp/control/WANCommonIFC1</controlURL>\n            <eventSubURL>/upnp/control/WANCommonIFC1</eventSubURL>\n            <SCPDURL>/gateicfgSCPD.xml</SCPDURL>\n          </service>\n        </serviceList>\n        <deviceList>\n          <device>\n            <deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>\n            <friendlyName>UPNP IGD</friendlyName>\n            <manufacturer>ZTE</manufacturer>\n            <manufacturerURL>http://www.zte.com</manufacturerURL>\n            <modelDescription>WanConnectionDevice ZTE HGW</modelDescription>\n            <modelName>F670LV9.0</modelName>\n            <modelNumber>V1.0</modelNumber>\n            <modelURL>http://www.zte.com</modelURL>\n            <UDN>uuid:80902345-123b-1234-e8b8-1111111111a</UDN>\n            <UPC></UPC>\n            <serialNumber>ABCVQJMM2B00799</serialNumber>\n            <serviceList>\n              <service>\n                <serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>\n                <serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>\n                <controlURL>/upnp/control/WANIPConn1</controlURL>\n                <eventSubURL>/upnp/control/WANIPConn1</eventSubURL>\n                <SCPDURL>/gateconnSCPD.xml</SCPDURL>\n              </service>\n              <service>\n                <serviceType>urn:schemas-upnp-org:service:WANIPv6FirewallControl:1</serviceType>\n                <serviceId>urn:upnp-org:serviceId:WANIPv6FwCtrl1</serviceId>\n                <controlURL>/upnp/control/WANIPv6FwCtrl1</controlURL>\n                <eventSubURL>/upnp/control/WANIPv6FwCtrl1</eventSubURL>\n                <SCPDURL>/gatev6fwctrlSCPD.xml</SCPDURL>\n              </service>\n            </serviceList>\n          </device>\n        </deviceList>\n      </device>\n    </deviceList>\n    <presentationURL>http://192.168.1.1</presentationURL>\n  </device>\n</root>\n">>,
                             4003,nolimit}]},
       {[],[]},
       {[],[]},
       new,[],nolimit,nolimit,
       {options,{undefined,[]},
                {undefined,[]},
                0,2,5,120000,2,disabled,debug,inet,default,default,[],
                undefined},
       {timers,[],undefined},
       httpc_manager,inactive})
(<0.221.0>) call httpc_manager:delete_session({{"192.168.1.1",52869},<0.221.0>},httpc_manager)
(<0.221.0>) returned from httpc_manager:delete_session/2 -> true
(<0.221.0>) returned from httpc_handler:terminate/2 -> ok
(<0.155.0>) call httpc_manager:handle_info({'DOWN',#Ref<0.4045007903.1400635403.260874>,process,<0.221.0>,normal},{state,[],httpc_manager__handler_db,
       {cookie_db,undefined,#Ref<0.4045007903.1400766476.261124>},
       httpc_manager__session_db,httpc_manager,
       {options,{undefined,[]},
                {undefined,[]},
                0,2,5,120000,2,disabled,debug,inet,default,default,[],
                undefined}})
(<0.155.0>) returned from httpc_manager:handle_info/2 -> {noreply,
                                                          {state,[],
                                                           httpc_manager__handler_db,
                                                           {cookie_db,
                                                            undefined,
                                                            #Ref<0.4045007903.1400766476.261124>},
                                                           httpc_manager__session_db,
                                                           httpc_manager,
                                                           {options,
                                                            {undefined,[]},
                                                            {undefined,[]},
                                                            0,2,5,120000,2,
                                                            disabled,debug,
                                                            inet,default,
                                                            default,[],
                                                            undefined}}}```
1 Like

I turned on the verbose, I am getting back the intended reply, but its just looping again and again and then just stops.

1 Like
<<"<?xml version=\"1.0\"?>\n<root xmlns=\"urn:schemas-upnp-org:device-1-0\">\n  <specVersion>\n    <major>1</major>\n    <minor>0</minor>\n  </specVersion>\n  <URLBase>http://192.168.1.1:52869</URLBase>\n  <device>\n    <deviceType>urn:schemas-upnp-org:device:InternetGatewayDevice:1</deviceType>\n    <friendlyName>UPNP IGD</friendlyName>\n    <manufacturer>ZTE</manufacturer>\n    <manufacturerURL>http://www.zte.com</manufacturerURL>\n    <modelDescription>ZTE Broadband Home Gateway</modelDescription>\n    <modelName>F670LV9.0</modelName>\n    <modelNumber>V1.0</modelNumber>\n    <modelURL>http://www.zte.com</modelURL>\n    <UDN>uuid:11111111-1111-1234-e8b8-45111126787e</UDN>\n    <UPC></UPC>\n     <serialNumber>ZTASDJNASD3454</serialNumber>\n    <iconList>\n      <icon>\n        <mimetype>image/gif</mimetype>\n        <width>118</width>\n        <height>119</height>\n        <depth>8</depth>\n        <url>/ligd.gif</url>\n      </icon>\n    </iconList>\n    <serviceList>\n      <service>\n        <serviceType>urn:schemas-microsoft-com:service:OSInfo:1</serviceType>\n        <serviceId>urn:microsoft-com:serviceId:OSInfo1</serviceId>\n        <controlURL>/upnp/control/OSInfo1</controlURL>\n        <eventSubURL>/upnp/event/OSInfo1</eventSubURL>\n        <SCPDURL>/gateinfoSCPD.xml</SCPDURL>\n      </service>\n    </serviceList>\n    <deviceList>\n      <device>\n        <deviceType>urn:schemas-upnp-org:device:WANDevice:1</deviceType>\n        <friendlyName>UPNP IGD</friendlyName>\n        <manufacturer>ZTE</manufacturer>\n        <manufacturerURL>http://www.zte.com</manufacturerURL>\n        <modelDescription>WAN Device on Linux IGD</modelDescription>\n        <modelName>F670LV9.0</modelName>\n        <modelNumber>V1.0</modelNumber>\n        <modelURL>http://www.zte.com</modelURL>\n        <UDN>uuid:11111111-1111-1234-e8b8-45111126787e</UDN>\n        <UPC></UPC>\n        <serialNumber>ZTASDJNASD3454</serialNumber>\n        <serviceList>\n          <service>\n            <serviceType>urn:schemas-upnp-org:service:WANCommonInterfaceConfig:1</serviceType>\n            <serviceId>urn:upnp-org:serviceId:WANCommonIFC1</serviceId>\n            <controlURL>/upnp/control/WANCommonIFC1</controlURL>\n            <eventSubURL>/upnp/control/WANCommonIFC1</eventSubURL>\n            <SCPDURL>/gateicfgSCPD.xml</SCPDURL>\n          </service>\n        </serviceList>\n        <deviceList>\n          <device>\n            <deviceType>urn:schemas-upnp-org:device:WANConnectionDevice:1</deviceType>\n            <friendlyName>UPNP IGD</friendlyName>\n            <manufacturer>ZTE</manufacturer>\n            <manufacturerURL>http://www.zte.com</manufacturerURL>\n            <modelDescription>WanConnectionDevice ZTE HGW</modelDescription>\n            <modelName>B879LV89.0</modelName>\n            <modelNumber>V1.0</modelNumber>\n            <modelURL>http://www.zte.com</modelURL>\n            <UDN>uuid:11111111-1111-1234-e8b8-45111126787e</UDN>\n            <UPC></UPC>\n            <serialNumber>ZTASDJNASD3454</serialNumber>\n            <serviceList>\n              <service>\n                <serviceType>urn:schemas-upnp-org:service:WANIPConnection:1</serviceType>\n                <serviceId>urn:upnp-org:serviceId:WANIPConn1</serviceId>\n                <controlURL>/upnp/control/WANIPConn1</controlURL>\n                <eventSubURL>/upnp/control/WANIPConn1</eventSubURL>\n                <SCPDURL>/gateconnSCPD.xml</SCPDURL>\n              </service>\n              <service>\n                <serviceType>urn:schemas-upnp-org:service:WANIPv6FirewallControl:1</serviceType>\n                <serviceId>urn:upnp-org:serviceId:WANIPv6FwCtrl1</serviceId>\n                <controlURL>/upnp/control/WANIPv6FwCtrl1</controlURL>\n                <eventSubURL>/upnp/control/WANIPv6FwCtrl1</eventSubURL>\n                <SCPDURL>/gatev6fwctrlASDF.xml</SCPDURL>\n              </service>\n            </serviceList>\n          </device>\n        </deviceList>\n      </device>\n    </deviceList>\n    <presentationURL>http://192.168.1.1</presentationURL>\n  </device>\n</root>\n">>,

this was the expected reply .which is seen in the verbose true, but the callback httpc_manager:handle_info/2 keep looping

1 Like

Cool, with a few options we’ve managed to find something! And yes you’re still hitting the area I thought there might have been a bug in. There might be a bug, or your server is misbehaving and hackney might be more tolerant in this particularly situation.

I would advise you to open a bug report after reading the bug reports wiki page

However, before you do it would be nice if this was reproducible (there might be enough info in your debug info though), but I realize this won’t be terribly simple (you’ll have to mimic the request response cycle in a bit of code that can be spun up by the OTP team in a very simple way).

It might also be nice if you could try a much older release of Erlang/OTP, such as OTP-23.3.4.18. It doesn’t narrow it down enough, but it would be nice to know if a bug was introduced at some point in time or if it’s been latent so to speak.

I might take a look further as well, but I must rest for now :slight_smile:

Edit:

FWIW, a guess would be httpc isn’t hitting a path that discerns it’s gotten the entire body (once again this could be because the server is misbehaving or just a bug in httpc). The remote end hangs up the phone, httpc gets this message (remote_close) and a retry ensues. After a certain number of retries and depending on the state (specifically if the staus is new or pipelined or keep_alive, iirc) you’ll eventually hit a clause that returns you the error that you’re getting back instead of the body (i.e. because httpc doesn’t understand it has all chunks already).

1 Like