membrane / api-gateway

API gateway for REST, OpenAPI, GraphQL and SOAP written in Java.
https://membrane-api.io
Apache License 2.0
465 stars 138 forks source link

Recursive output of WARN HttpTransport:126 - Still waiting for running exchanges to finish #161

Closed serialbandicoot closed 1 year ago

serialbandicoot commented 10 years ago

I get the following message continuously outputting to the console and it only stops when I restart membrane.

WARN HttpTransport:126 - Still waiting for running exchanges to finish. (Set <transport forceSocketCloseOnHotDeployAfter="30000"> to a lower value to forcibly close connections more quickly.

  1. Use the following xml content in the proxies.xml (between spring:beans)
<router>
 <serviceProxy port="20000" >
 <log headerOnly="false" level="DEBUG"/>
 <target host="localhost" port="1080"/>
 </serviceProxy>
</router>
  1. I've set up a mock, configured to GET path /aaa.* on port 1080, with mock-server
  2. Send in a GET /aaaaaaa... (I had this set to 9999 chars of "a")
  3. Change something on the proxies.xml and Save the file e.g. level ="INFO"
  4. Kill the GET request

This will cause the Warning above to keep logging to the output even though the original GET request has been killed.

This has been resolved by changing the <router> to <router hotDeploy="false">

However this does mean that we can no longer perform hot deploys for fear of triggering this issue.

rrayst commented 10 years ago

This is working as designed.

For Membrane Service Proxy to reload its configuration, the following steps need to be completed:

  1. stop accepting new HTTP requests
  2. wait for all running HTTP requests to finish
  3. close the ports (20000 in your case)
  4. reload the configuration
  5. open the ports (20000 in your case)
  6. start accepting HTTP requests again

You are stuck in step 2. Step 2 will not complete, until your target server (localhost:1080) has responded to all HTTP requests (that were already running when the restart process started at step 1) and all HTTP clients have completely received their responses.

There is a timeout for waiting for step 2 to complete. The default value for this is 30 seconds. After this time, Membrane Service Proxy will not wait any longer, but simply close the incoming TCP connection and continue with step 3.

You can change this timeout using <transport forceSocketCloseOnHotDeployAfter="30000" /> . See also http://membrane-soa.org/service-proxy-doc/4.0/configuration/reference/transport.htm .

E.g.

    <router>
        <transport forceSocketCloseOnHotDeployAfter="30000">
            <ruleMatching/>
            <dispatching/>
            <userFeature/>
            <httpClient />
        </transport>

        <serviceProxy ...>
            ...
        </serviceProxy>
    </router>

If you don't have a problem with TCP connections simply getting closed when you do a Membrane Service Proxy configuration reload, feel free to lower this value. Then the restart process will complete quicker.

serialbandicoot commented 10 years ago

I've tried your suggestion with the following and repeated my steps above.

<router>
 <transport forceSocketCloseOnHotDeployAfter="30000"/>
 <serviceProxy port="20000" >
 <log headerOnly="false" level="DEBUG"/>
 <target host="localhost" port="1080"/>
 </serviceProxy>
</router>

The Warning message continues after 30 seconds and it seems that the forceSocketCloseOnHotDeployAfter does not move onto step 3 as suggested.

UPDATE: I also change the timeout to 1 and now I get the following Warning:

WARN HttpTransport:126 - Still waiting for running exchanges to finish. (Set &lt;transport forceSocketCloseOnHotDeployAfter="1"&gt; to a lower value to forcibly close connections more quickly.