2017-03-29 1 views
2

J'ai écrit la classe simple ProxyServlet étend org.eclipse.jetty.proxy.ProxyServlet.Transparent et l'a utilisé avec org.eclipse.jetty.server.Server .Dans 1 de beaucoup de demandes j'obtiens l'état de réponse HTTP 502 Bad Gateway

Lorsque je reçois de manière monotone la même requête, j'obtiens parfois une erreur.

J'ai essayé la jetée des versions: 9.4.3.v20170317 et 9.3.15.v20161220.

Connexion de la demande réussie est:

2017-03-29 16:11:01 [qtp922145372-30] DEBUG 65e620b0:71 - 886655093 rewriting: http://localhost:8282/api/state-get?hash=1490793061907 -> http://localhost:8888/api/state-get?hash=1490793061907 
2017-03-29 16:11:01 [qtp922145372-30] DEBUG 65e620b0:539 - 886655093 proxying to upstream: 
GET /api/state-get?hash=1490793061907 HTTP/1.1 
Cookie: JSESSIONID=node01lgbitpmvb4lg19wqy2t1vbhhj0.node0 
Cache-Control: no-cache 
Accept: application/json, text/plain,/
Connection: keep-alive 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36 
Referer: http://localhost:8282/ 
Host: localhost:8282 
Pragma: no-cache 
Accept-Encoding: gzip, deflate, sdch, br 
Accept-Language: en-US,en;q=0.8,ru;q=0.6 
auth-user: aW50XGFkbWlu 
auth-roles: 0JDQtNC80LjQvdC40YHRgtGA0LDRgtC+0YA= 

HttpRequest[GET /api/state-get HTTP/1.1]@f5d34a2 

2017-03-29 16:11:01 [ProxyServlet-65e620b0-37] DEBUG 65e620b0:599 - 886655093 proxying to downstream: 
HttpResponse[HTTP/1.1 200 OK]@66b83d74 
Date: Wed, 29 Mar 2017 13:11:01 GMT 
Content-Type: application/json;charset=UTF-8 
Content-Length: 67 
Server: Jetty(9.4.3.v20170317) 

2017-03-29 16:11:01 [ProxyServlet-65e620b0-37] DEBUG 65e620b0:138 - 886655093 proxying content to downstream: 67 bytes 
2017-03-29 16:11:01 [ProxyServlet-65e620b0-37] DEBUG 65e620b0:618 - 886655093 proxying successful 
2017-03-29 16:11:01 [ProxyServlet-65e620b0-37] DEBUG 65e620b0:240 - 886655093 proxying complete 

Connexion de la demande d'erreur est:

2017-03-29 16:10:31 [qtp922145372-30] DEBUG 65e620b0:71 - 424608794 rewriting: http://localhost:8282/api/state-get?hash=1490793031907 -> http://localhost:8888/api/state-get?hash=1490793031907 
2017-03-29 16:10:31 [qtp922145372-30] DEBUG 65e620b0:539 - 424608794 proxying to upstream: 
GET /api/state-get?hash=1490793031907 HTTP/1.1 
Cookie: JSESSIONID=node01lgbitpmvb4lg19wqy2t1vbhhj0.node0 
Cache-Control: no-cache 
Accept: application/json, text/plain,/
Connection: keep-alive 
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.110 Safari/537.36 
Referer: http://localhost:8282/ 
Host: localhost:8282 
Pragma: no-cache 
Accept-Encoding: gzip, deflate, sdch, br 
Accept-Language: en-US,en;q=0.8,ru;q=0.6 
auth-user: aW50XGFkbWlu 
auth-roles: 0JDQtNC80LjQvdC40YHRgtGA0LDRgtC+0YA= 

HttpRequest[GET /api/state-get HTTP/1.1]@34e1eb9e 

2017-03-29 16:10:31 [ProxyServlet-65e620b0-38] DEBUG 65e620b0:627 - 424608794 proxying failed 
java.io.EOFException: [email protected](l:/127.0.0.1:47382 <-> r:localhost/127.0.0.1:8888,closed=false)=>[email protected]([email protected] req=TERMINATED/[email protected] res=PENDING/[email protected])[[email protected](req=QUEUED,snd=COMPLETED,failure=null)[[email protected]{s=START}],[email protected](rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]]<[email protected]{localhost/127.0.0.1:8888<->/127.0.0.1:47382,ISHUT,fill=-,flush=-,to=5/30000}{io=0/0,kio=0,kro=1}->[email protected](l:/127.0.0.1:47382 <-> r:localhost/127.0.0.1:8888,closed=false)=>[email protected]([email protected] req=TERMINATED/[email protected] res=PENDING/[email protected])[[email protected](req=QUEUED,snd=COMPLETED,failure=null)[[email protected]{s=START}],[email protected](rsp=IDLE,failure=null)[HttpParser{s=CLOSED,0 of -1}]] 
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.earlyEOF(HttpReceiverOverHTTP.java:310) [jetty-client-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1418) [jetty-http-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.shutdown(HttpReceiverOverHTTP.java:196) [jetty-client-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.process(HttpReceiverOverHTTP.java:143) [jetty-client-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.client.http.HttpReceiverOverHTTP.receive(HttpReceiverOverHTTP.java:70) [jetty-client-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.client.http.HttpChannelOverHTTP.receive(HttpChannelOverHTTP.java:130) [jetty-client-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.client.http.HttpConnectionOverHTTP.onFillable(HttpConnectionOverHTTP.java:116) [jetty-client-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279) [jetty-io-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:110) [jetty-io-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124) [jetty-io-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.util.thread.Invocable.invokePreferred(Invocable.java:122) [jetty-util-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.util.thread.strategy.ExecutingExecutionStrategy.invoke(ExecutingExecutionStrategy.java:58) [jetty-util-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.produceConsume(ExecuteProduceConsume.java:201) [jetty-util-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.util.thread.strategy.ExecuteProduceConsume.run(ExecuteProduceConsume.java:133) [jetty-util-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:672) [jetty-util-9.4.3.v20170317.jar:9.4.3.v20170317] 
at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:590) [jetty-util-9.4.3.v20170317.jar:9.4.3.v20170317] 
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121] 
2017-03-29 16:10:31 [ProxyServlet-65e620b0-38] DEBUG 65e620b0:240 - 424608794 proxying complete 

Mise à jour:

Je ne sais pas pourquoi, mais parfois la connexion entre proxy et cible le serveur est fermé. L'événement de requête n'atteint pas le servlet sur le serveur. Voici le code du serveur:

  server = new Server(port); 

      final String webDir = isNotBlank(webappPath) ? webappPath : new ClassPathResource(WEBAPP_DIR_NAME).getURI().toString(); 
      final WebAppContext webAppContext = new WebAppContext(webDir, "/" + context); 

      webAppContext.setInitParameter("org.eclipse.jetty.servlet.Default.gzip", "true"); 
      webAppContext.setInitParameter("org.eclipse.jetty.servlet.Default.cacheControl", "max-age=3600,public"); 

      final ServletHolder apiServletHolder = new ServletHolder(new ApiServlet(getPluginResponseListener(), getPluginListener(), getPluginInfoRequestListener())); 
      final String apiServletMapping = "/" + ApiServlet.SERVLET_PATH + "/*"; 

      webAppContext.addServlet(apiServletHolder, apiServletMapping); 
      webAppContext.setMaxFormContentSize(10 * 1024 * 1024); 
      webAppContext.setErrorHandler(getErrorHandler()); 

      server.setHandler(webAppContext); 

      server.start(); 

Wireshark info:

demande Succès: enter image description here

Bad demande de la passerelle: enter image description here

lignes de demande comparer: enter image description here

enter image description here

enter image description here

enter image description here

+0

Eh bien, 502 est (ou peut être) une erreur de proxy. Je pense que jetty vous donne le code 502, car le système backend ne gérera pas votre requête. – slowy

Répondre

0

Le résultat est: ce problème est de réseau interne, parce que d'autres services dans mon réseau se rencontrent le même problème. Solution: renvoyer la requête sur l'erreur HTTP 502.