<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>
<div>Interesting finding, after adding some debug printing to print out headers, now I can’t repro the issue:</div>
<div><br>
</div>
</div>
</div>
<div>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(236, 236, 21); background-color: rgb(0, 0, 0);">
  64 <span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(40, 239, 239); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  65 </span>
%% Invoke REST API calls via same inets/httpc processes</p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  66 </span>
same_inets_for_calls_test() <span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">
-></span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(236, 236, 21); background-color: rgb(0, 0, 0);">
  67 </p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  68 </span>
    inets:start(),</p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(236, 236, 21); background-color: rgb(0, 0, 0);">
  69 <span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(255, 64, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  70 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #28efef">BeginUrl</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #6ce2ff">?API_BASE</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">++</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span>"begin_media_post"<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(255, 64, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  71 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #28efef">BeginH1</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[{</span>"x-pryvy-authorization-status"<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span>"Unknown"<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(255, 64, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  72 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #28efef">BeginHeaders</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[{</span>"x-pryvy-authorized-userid"<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span>"100"<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">|</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #28efef">BeginH1</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(40, 239, 239); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  73 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">{</span><span style="font-variant-ligatures: no-common-ligatures; color: #ff40ff">ok</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">{{</span>_<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>BeginStatus<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>BeginResponseReason<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>BeginResponseHeaders<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(40, 239, 239); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  74 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">         
</span>BeginResponseBody<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}}</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">=</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  75 </span>
        httpc:request(<span style="font-variant-ligatures: no-common-ligatures; color: #ff40ff">post</span>,
<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">{</span><span style="font-variant-ligatures: no-common-ligatures; color: #28efef">BeginUrl</span>,
<span style="font-variant-ligatures: no-common-ligatures; color: #28efef">BeginHeaders</span>,
<span style="font-variant-ligatures: no-common-ligatures; color: #6ce2ff">?CONTENT_TYPE_JSON</span>,</p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(108, 226, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  76 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">           
</span>?SAMPLE_JSON_CONTENT<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">),</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(255, 64, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  77 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    io:format(</span>standard_io<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>"resason: <span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">
~p~n</span> headers: <span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">
~p~n</span> body: <span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">
~p~n</span>"<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(40, 239, 239); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  78 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">             
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[</span>BeginResponseReason<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>BeginResponseHeaders<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>BeginResponseBody<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">),</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(108, 226, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  79 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
?assertEqual<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">(</span>?HTTP_UNAUTH<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span><span style="font-variant-ligatures: no-common-ligatures; color: #28efef">BeginStatus</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">),</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(236, 236, 21); background-color: rgb(0, 0, 0);">
  80 <span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(255, 64, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  81 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #28efef">EndUrl</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #6ce2ff">?API_BASE</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">++</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span>"end_media_post"<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(255, 64, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  82 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #28efef">EndH1</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[{</span>"x-pryvy-authorization-status"<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span>"Unknown"<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(255, 64, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  83 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #28efef">EndHeaders</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">=</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[{</span>"x-pryvy-authorized-userid"<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span>"100"<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">|</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #28efef">EndH1</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(40, 239, 239); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  84 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">{</span><span style="font-variant-ligatures: no-common-ligatures; color: #ff40ff">ok</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">{{</span>_<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>EndStatus<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>EndResponseReason<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>EndResponseHeaders<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(40, 239, 239); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  85 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">         
</span>EndResponseBody<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}}</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">=</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  86 </span>
        httpc:request(<span style="font-variant-ligatures: no-common-ligatures; color: #ff40ff">post</span>,
<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">{</span><span style="font-variant-ligatures: no-common-ligatures; color: #28efef">EndUrl</span>,
<span style="font-variant-ligatures: no-common-ligatures; color: #28efef">EndHeaders</span>,
<span style="font-variant-ligatures: no-common-ligatures; color: #6ce2ff">?CONTENT_TYPE_JSON</span>,</p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(108, 226, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  87 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">           
</span>?SAMPLE_JSON_CONTENT<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">}</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">),</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(255, 64, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  88 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    io:format(</span>standard_io<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>"resason: <span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">
~p~n</span> headers: <span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">
~p~n</span> body: <span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">
~p~n</span>"<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(40, 239, 239); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  89 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">             
</span><span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">[</span>EndResponseReason<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>EndResponseHeaders<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span>EndResponseBody<span style="font-variant-ligatures: no-common-ligatures; color: #ffdddd">]</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">),</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(108, 226, 255); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  90 </span>
<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span>
?assertEqual<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">(</span>?HTTP_UNAUTH<span style="font-variant-ligatures: no-common-ligatures; color: #29f914">,
</span><span style="font-variant-ligatures: no-common-ligatures; color: #28efef">EndStatus</span><span style="font-variant-ligatures: no-common-ligatures; color: #29f914">),</span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(236, 236, 21); background-color: rgb(0, 0, 0);">
  91 <span style="font-variant-ligatures: no-common-ligatures; color: #29f914">    </span></p>
<p style="margin: 0px; font-size: 12px; font-family: 'Andale Mono'; color: rgb(41, 249, 20); background-color: rgb(0, 0, 0);">
<span style="font-variant-ligatures: no-common-ligatures; color: #ecec15">  92 </span>
    inets:stop().</p>
</div>
<div><br>
</div>
<div>Smells like the inets/httpc timing issue?</div>
<div><br>
</div>
<div>Thanks,</div>
<div>Shawn</div>
<div><br>
</div>
<span id="OLK_SRC_BODY_SECTION">
<div style="font-family:Calibri; font-size:12pt; text-align:left; color:black; BORDER-BOTTOM: medium none; BORDER-LEFT: medium none; PADDING-BOTTOM: 0in; PADDING-LEFT: 0in; PADDING-RIGHT: 0in; BORDER-TOP: #b5c4df 1pt solid; BORDER-RIGHT: medium none; PADDING-TOP: 3pt">
<span style="font-weight:bold">From: </span>Shawn Debnath<br>
<span style="font-weight:bold">Date: </span>Thursday, January 15, 2015 at 11:49 AM<br>
<span style="font-weight:bold">To: </span>Erlang Questions<br>
<span style="font-weight:bold">Subject: </span>[erlang-questions] inets/httpc bad match issue for 2 post requests<br>
</div>
<div><br>
</div>
<div>
<div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; color: rgb(0, 0, 0); font-size: 14px; font-family: Calibri, sans-serif;">
<div>
<div>
<div>
<div>Hi there,</div>
<div><br>
</div>
<div>Wondering if anyone can shed some light on this issue I am seeing. </div>
<div><br>
</div>
<div>I am trying to understand what may be causing **error:{badmatch,{error,socket_closed_remotely}} when using the same inets process to do 2 POST/PUT requests. The same code works just fine when issuing the same rest API calls to two separate inets processes
 or when issuing 2 GET requests to the same inets process. </div>
<div><br>
</div>
<div>Using webmachine on the server side which is not reporting any errors, and looking at the WMTRACEs, it correctly returns HTTP 401 error, which is expected.</div>
<div><br>
</div>
<div>Test source and output can be found at: <a href="http://pastebin.com/9DFzxLps">
http://pastebin.com/9DFzxLps</a></div>
<div><br>
</div>
<div>Thanks,</div>
<div>Shawn</div>
</div>
<div><br>
</div>
<div>
<div id=""></div>
</div>
</div>
</div>
</div>
</div>
</span>
</body>
</html>