--proxy--all is not fully working and creating exception in particular case

瀏覽次數:181 次
跳到第一則未讀訊息

sumit_shivhare

未讀,
2016年4月13日 清晨6:21:122016/4/13
收件者:wiremock-user
Hello Tom,

Here is my scenario,

i have one Client exe which is an application itself and use to create some designs and it connects to one kind of server which acts as database for my client the communication between them is based on http (thats means database server is local). 
but as in many cases it is very difficult to create failed response from server but those are necessary in order to make client handle such responses.

so the best solution is to create a mock server using wiremock with which my client connects and in the extension i can write my extension which will responce to perticular request and for other requests it will proxy to the server and the server should response back to the client exe. (this my current requirement)

i have done the preparetion and created the wiremock.jar with my extension included and run with the following command for e.g. 

"java -jar NewWiremock.jar --port 2808 --proxy-all="http://myserver:1090"  --extension com.github.tomakehurst.wiremock.extension.sWExtension -verbose"



then, i run the client with the following configuration hostname:- localhost, port:- 2808, uri:- myuri after that client request wiremock for connection (i also got request header in my extension and can print it as well)  which wiremock forwarded to myserver as 
"
"

which pops up login dialog from myserver then i put username password in it and then ok to the dialog which offcourse athenticated by server but the problem is in the meantime the wiremock caused the following exception.while messages are exchanged between client and server

"
       java.lang.IllegalArgumentException: MIME type may not contain reserved characters
        at wiremock.org.apache.http.util.Args.check(Args.java:36)
        at wiremock.org.apache.http.entity.ContentType.create(ContentType.java:181)
        at wiremock.org.apache.http.entity.ContentType.create(ContentType.java:209)
        at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.buildEntityFrom(ProxyResponseRenderer.java:165)
        at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.addBodyIfPostPutOrPatch(ProxyResponseRenderer.j
        at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.render(ProxyResponseRenderer.java:75)
        at com.github.tomakehurst.wiremock.http.StubResponseRenderer.render(StubResponseRenderer.java:47)
        at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:40)
        at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.service(Jetty6HandlerDispatchingSer
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at wiremock.org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at wiremock.org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
        at wiremock.org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
        at wiremock.org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at wiremock.org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at wiremock.org.mortbay.jetty.Server.handle(Server.java:326)
        at wiremock.org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at wiremock.org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
        at wiremock.org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
        at wiremock.org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at wiremock.org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at wiremock.org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at com.github.tomakehurst.wiremock.jetty6.DelayableSocketConnector$1.run(DelayableSocketConnector.java:49)
        at wiremock.org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)
"

as a result the connection failed and we are not able to work with such scenario.
however if i use internet browser(here google chrome is my client) to connect with wiremock (which ultimatly forward request to myserver) is working fine 

that means through browser i type http://localhost:2808/myuri, i got login dialog from myserver and get successful connection with myserver and able to work with it.
however in this case after connection we are not getting requests in my extension.

so can please have a look into the issue described above and let us know what should i do to make it work.

thank you,
Best regards,
Sumit


Tom Akehurst

未讀,
2016年4月15日 上午8:24:532016/4/15
收件者:wiremock-user
Can you post a full dump of the request you're making that causes this failure e.g. via tcpdump?

It looks like your HTTP client is sending something in the Content-Type header that the Apache HTTP library's ContentType class can't parse.

Do you know how the Content-Type header is being set? Is it something you can tweak yourself?

sumit_shivhare

未讀,
2016年4月18日 清晨6:43:282016/4/18
收件者:wiremock-user
Hello Tom,
you are right the request send to the server is in encripted form which wiremock is not able to decript it we have some API's to decript the requests but i don know how to modify the request in our extension so that it will be forwarded to actual server.

Also, one more question ?
do we get the response from the myserver directly to wiremock in case of proxy-all or myserver is expected to send response direclty to client exe???

however the full dump of the request is 
2016-04-18 16:05:24.843 Request received:
POST /ematrix/mcs/SidlChunked?cmd=Sidl+Request&ProcName=PostLogonProcessor HTTP/1.1
Connection: Keep-Alive
User-Agent: CATIA HTTP CLIENT v2.1-DS
Host: localhost:2808
Cache-Control: no-cache
Cookie: JSESSIONID=27128C3D638C32C688177B27E45530D5
Content-Type: application/octet-stream, application/octetstream
Content-Length: 253

   6   ?☺   ☺   ☺   ♥☺  ♦   ?:  ↕   PostLogonProcessor  ►♥    x?M?]♂?0¶???_∟???♠?"7$1C0?Zl?@??????"??}
We are in sWExtension
/ematrix/mcs/SidlChunked?cmd=Sidl+Request&ProcName=PostLogonProcessor
-----------Request body--------------
   6   ?☺   ☺   ☺   ♥☺  ♦   ?:  ↕   PostLogonProcessor  ►♥    x?M?]♂?0¶???_∟???♠?"7$1C0?Zl?@??????"??}


2016-04-18 16:05:24.884 /ematrix/mcs/SidlChunked
java.lang.IllegalArgumentException: MIME type may not contain reserved characters
        at wiremock.org.apache.http.util.Args.check(Args.java:36)
        at wiremock.org.apache.http.entity.ContentType.create(ContentType.java:181)
        at wiremock.org.apache.http.entity.ContentType.create(ContentType.java:209)
        at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.buildEntityFrom(ProxyResponseRendere
        at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.addBodyIfPostPutOrPatch(ProxyRespons
        at com.github.tomakehurst.wiremock.http.ProxyResponseRenderer.render(ProxyResponseRenderer.java:75
        at com.github.tomakehurst.wiremock.http.StubResponseRenderer.render(StubResponseRenderer.java:47)
        at com.github.tomakehurst.wiremock.http.AbstractRequestHandler.handle(AbstractRequestHandler.java:
        at com.github.tomakehurst.wiremock.jetty6.Jetty6HandlerDispatchingServlet.service(Jetty6HandlerDis
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
        at wiremock.org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:511)
        at wiremock.org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:401)
        at wiremock.org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:766)
        at wiremock.org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
        at wiremock.org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
        at wiremock.org.mortbay.jetty.Server.handle(Server.java:326)
        at wiremock.org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:542)
        at wiremock.org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:945)
        at wiremock.org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:756)
        at wiremock.org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:218)
        at wiremock.org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
        at wiremock.org.mortbay.jetty.bio.SocketConnector$Connection.run(SocketConnector.java:228)
        at com.github.tomakehurst.wiremock.jetty6.DelayableSocketConnector$1.run(DelayableSocketConnector.
        at wiremock.org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:582)

thank you,
Regards,
Sumit
回覆所有人
回覆作者
轉寄
0 則新訊息