Giter VIP home page Giter VIP logo

Comments (14)

sveldhuisen avatar sveldhuisen commented on July 20, 2024

Some logging on the REST client sending HTTP GET and POST with WinFoom configured as a proxy server:

[04/08/22 14:27:58.845]: TRACE:  Exact Globe: RESTSubscriptionShim.execute() :
[04/08/22 14:27:58.845]: TRACE:  Exact Globe: customHandler
[04/08/22 14:27:58.845]: TRACE:  Exact Globe: customHandler: class-name == 'BusinessEntity'
[04/08/22 14:27:58.845]: TRACE:  Exact Globe: Custom: preparing GET to http://iis-webserver.local.domain:8020/services/Exact.Entity.REST.EG/Resource?$top=1&$filter=ID
[04/08/22 14:27:58.846]: TRACE:  Exact Globe: Resetting headers
[04/08/22 14:27:58.846]: TRACE:  Exact Globe: Setting the following HTTP request properties:
 Authorization: <content suppressed>
[04/08/22 14:27:58.846]: TRACE:  Exact Globe:  Accept:application/json
[04/08/22 14:27:58.846]: TRACE:  Exact Globe:  ServerName:sqldb.local.domain
[04/08/22 14:27:58.847]: TRACE:  Exact Globe:  DatabaseName:123
[04/08/22 14:27:58.847]: TRACE:  Exact Globe:  Cache-Control:no-store, no-cache
[04/08/22 14:27:58.847]: TRACE:  Exact Globe:  Content-Type:application/json; charset=utf-8
[04/08/22 14:27:58.847]: TRACE:  Exact Globe: Annonymous login
[04/08/22 14:27:58.847]: TRACE:  Exact Globe: Did a HTTP GET with 0 bytes of data to http://iis-webserver.local.domain:8020/services/Exact.Entity.REST.EG/Resource?$top=1&$filter=ID
[04/08/22 14:27:58.848]: TRACE:  Exact Globe: *******************************************************
[04/08/22 14:27:58.848]: TRACE:  Exact Globe: **********************LOGGING REQUEST******************
[04/08/22 14:27:58.848]: TRACE:  Exact Globe: *******************************************************
[04/08/22 14:27:58.848]: TRACE:  Exact Globe: Request URL :http://iis-webserver.local.domain:8020/services/Exact.Entity.REST.EG/Resource?$top=1&$filter=ID
[04/08/22 14:27:58.849]: TRACE:  Exact Globe: Http Method : GET
[04/08/22 14:27:58.849]: TRACE:  Exact Globe: Sending http request with below headers :-
[04/08/22 14:27:58.849]: TRACE:  Exact Globe: Authorization: <content suppressed>
[04/08/22 14:27:58.849]: TRACE:  Exact Globe: Accept: application/json
[04/08/22 14:27:58.849]: TRACE:  Exact Globe: ServerName: sqldb.local.domain
[04/08/22 14:27:58.850]: TRACE:  Exact Globe: DatabaseName: 123
[04/08/22 14:27:58.850]: TRACE:  Exact Globe: Cache-Control: no-store, no-cache
[04/08/22 14:27:58.850]: TRACE:  Exact Globe: Content-Type: application/json; charset=utf-8
[04/08/22 14:27:58.850]: TRACE:  Exact Globe: ***************************END**************************
[04/08/22 14:27:59.393]: TRACE:  Exact Globe: ********************************************************
[04/08/22 14:27:59.394]: TRACE:  Exact Globe: ***********************LOGGING RESPONSE*****************
[04/08/22 14:27:59.394]: TRACE:  Exact Globe: ********************************************************
[04/08/22 14:27:59.394]: TRACE:  Exact Globe: Http response code : 200
[04/08/22 14:27:59.394]: TRACE:  Exact Globe: Http response status : HTTP/1.1 200 OK
[04/08/22 14:27:59.394]: TRACE:  Exact Globe: Getting http response with below headers :-
[04/08/22 14:27:59.395]: TRACE:  Exact Globe: Via: 1.1 winfoom
[04/08/22 14:27:59.395]: TRACE:  Exact Globe: Cache-Control: no-cache
[04/08/22 14:27:59.395]: TRACE:  Exact Globe: Content-Length: 20
[04/08/22 14:27:59.395]: TRACE:  Exact Globe: Content-Type: application/json;odata=verbose;charset=utf-8
[04/08/22 14:27:59.395]: TRACE:  Exact Globe: Server: Microsoft-HTTPAPI/2.0
[04/08/22 14:27:59.396]: TRACE:  Exact Globe: X-Content-Type-Options: nosniff
[04/08/22 14:27:59.396]: TRACE:  Exact Globe: DataServiceVersion: 2.0;
[04/08/22 14:27:59.396]: TRACE:  Exact Globe: Date: Fri, 08 Apr 2022 12:27:58 GMT
[04/08/22 14:27:59.396]: TRACE:  Exact Globe: Sending http response with body :-
[04/08/22 14:27:59.396]: TRACE:  Exact Globe: {"d":{"results":[]}}
[04/08/22 14:27:59.396]: TRACE:  Exact Globe: **********************END*****************************
[04/08/22 14:27:59.397]: TRACE:  Exact Globe: Response code and message: 200 OK

[04/08/22 14:27:59.420]: TRACE:  Exact Globe: RESTSubscriptionShim.execute() :
[04/08/22 14:27:59.420]: TRACE:  Exact Globe: customHandler
[04/08/22 14:27:59.420]: TRACE:  Exact Globe: customHandler: class-name == 'BusinessEntity'
[04/08/22 14:27:59.421]: TRACE:  Exact Globe: Custom: preparing POST to http://iis-webserver.local.domain:8020/services/Exact.Entity.REST.EG/Resource
[04/08/22 14:27:59.421]: TRACE:  Exact Globe: Resetting headers
[04/08/22 14:27:59.421]: TRACE:  Exact Globe: Setting the following HTTP request properties:
 Authorization: <content suppressed>
[04/08/22 14:27:59.422]: TRACE:  Exact Globe:  Accept:application/json
[04/08/22 14:27:59.422]: TRACE:  Exact Globe:  ServerName:sqldb.local.domain
[04/08/22 14:27:59.422]: TRACE:  Exact Globe:  DatabaseName:123
[04/08/22 14:27:59.422]: TRACE:  Exact Globe:  Cache-Control:no-store, no-cache
[04/08/22 14:27:59.422]: TRACE:  Exact Globe:  Content-Type:application/json; charset=utf-8
[04/08/22 14:27:59.423]: TRACE:  Exact Globe: Annonymous login
[04/08/22 14:27:59.423]: TRACE:  Exact Globe: Did a HTTP POST with 239 bytes of data to http://iis-webserver.local.domain:8020/services/Exact.Entity.REST.EG/Resource
[04/08/22 14:27:59.423]: TRACE:  Exact Globe: *******************************************************
[04/08/22 14:27:59.423]: TRACE:  Exact Globe: **********************LOGGING REQUEST******************
[04/08/22 14:27:59.424]: TRACE:  Exact Globe: *******************************************************
[04/08/22 14:27:59.424]: TRACE:  Exact Globe: Request URL :http://iis-webserver.local.domain:8020/services/Exact.Entity.REST.EG/Resource
[04/08/22 14:27:59.424]: TRACE:  Exact Globe: Http Method : POST
[04/08/22 14:27:59.424]: TRACE:  Exact Globe: Sending http request with below headers :-
[04/08/22 14:27:59.425]: TRACE:  Exact Globe: Authorization: <content suppressed>
[04/08/22 14:27:59.425]: TRACE:  Exact Globe: Accept: application/json
[04/08/22 14:27:59.425]: TRACE:  Exact Globe: ServerName: sqldb.local.domain
[04/08/22 14:27:59.425]: TRACE:  Exact Globe: DatabaseName: 123
[04/08/22 14:27:59.425]: TRACE:  Exact Globe: Cache-Control: no-store, no-cache
[04/08/22 14:27:59.426]: TRACE:  Exact Globe: Content-Type: application/json; charset=utf-8
[04/08/22 14:27:59.426]: TRACE:  Exact Globe: ***************************END**************************
[04/08/22 14:27:59.426]: TRACE:  Remote Loader: SubscriptionShim.execute() returned:
[04/08/22 14:27:59.427]: TRACE:  IOException: iis-webserver.local.domain:8020 failed to respond</status>

from winfoom.

ecovaci avatar ecovaci commented on July 20, 2024

You are absolutely right, and I had to assume this unwanted behavior since the application inception. The issue starts with the fact that a MITM(man-in-the-middle) piece of software like Winfoom cannot honor connection keep-alive HTTP directive for obvious reasons, hence the socket close action on each request. Fortunately this happens only at software level - behind the scene, there are some mechanisms to reuse connections (at OS level) - hence the performance doesn't drop. Since Keep-alive connections are enabled by default in HTTP/1.1 the only way to notify a client about the socket close action is by adding Connection: close header to override the default behavior. It would likely work, but I didn't try.

from winfoom.

sveldhuisen avatar sveldhuisen commented on July 20, 2024

Hi Eugen,

That is a blazing fast response, thanks for your input in this matter. Unfortunately I don't have full control on the code of the REST client, so I can't change the behaviour on that side (i.e. remove the connection pooling or Keepalive headers).

As I'm not very familiar with the WinFoom code yet, could you give me some hints were I can add the Connection: Close header, without affecting the HTTP connections to the actual endpoint?

from winfoom.

ecovaci avatar ecovaci commented on July 20, 2024

It is very simple to add, I will create a new branch and do it myself. I'll let you know when it's done

from winfoom.

sveldhuisen avatar sveldhuisen commented on July 20, 2024

I think I have found the right spot:

diff --git a/src/main/java/org/kpax/winfoom/proxy/processor/NonConnectClientConnectionProcessor.java b/src/main/java/org/kpax/winfoom/proxy/processor/NonConnectClientConnectionProcessor.java
index 4f420f9..d317ba2 100644
--- a/src/main/java/org/kpax/winfoom/proxy/processor/NonConnectClientConnectionProcessor.java
+++ b/src/main/java/org/kpax/winfoom/proxy/processor/NonConnectClientConnectionProcessor.java
@@ -108,6 +108,7 @@ class NonConnectClientConnectionProcessor extends ClientConnectionProcessor {
                             clientConnection.write(header);
                         }
                     }
+                    clientConnection.write("Connection: close");

                     // Empty line marking the end
                     // of header's section

from winfoom.

ecovaci avatar ecovaci commented on July 20, 2024

Yes, you still have to remove the existent one contained by the response (if any). See test-connection-close branch, I have made the modification. Can you take from here? Otherwise I can make a pre-release for you.

from winfoom.

sveldhuisen avatar sveldhuisen commented on July 20, 2024

Yes, you still have to remove the existent one contained by the response (if any). See test-connection-close branch, I have made the modification. Can you take from here? Otherwise I can make a pre-release for you.

I can take it from there. Thank you very much!

from winfoom.

ecovaci avatar ecovaci commented on July 20, 2024

You welcome. Please let me know how it worked.

from winfoom.

sveldhuisen avatar sveldhuisen commented on July 20, 2024

Just made a maven build and did some testing: it works beautifully. Thanks again!

from winfoom.

ecovaci avatar ecovaci commented on July 20, 2024

If there are no side effects, I can merge it into master and make a new release.

from winfoom.

sveldhuisen avatar sveldhuisen commented on July 20, 2024

If there are no side effects, I can merge it into master and make a new release.

For my specific usecase there are no side effects. Ofcourse I did not do a full unit test on all the functionality. But I expect no side effects as the socket close was already in place: this only fixes the client behaviour about communicating the connection has been closed.

from winfoom.

ecovaci avatar ecovaci commented on July 20, 2024

I'll do some testing myself then issue a new release. Thanks for your interest in this project.

from winfoom.

sveldhuisen avatar sveldhuisen commented on July 20, 2024

You are welcome! Before making a release: I noticed that using encode() for the password within a JSON file is not being interpreted. I'll file a new issue for that.

from winfoom.

ecovaci avatar ecovaci commented on July 20, 2024

Solved in v4.0.3

from winfoom.

Related Issues (10)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.