akamai / esi-test-server-docker

A dockerized version of Akamai's Edge Side Includes Test Server (ETS).
32 stars 6 forks source link

ESI: Invalid method encountered #19

Open dipak7587 opened 1 year ago

dipak7587 commented 1 year ago

I am using the playground for resolving ESI fragmentation.
`

`

Output: ` /Debugging Section/

[2034]: Source encoding detected: UTF-8. GEO: georegion=246,country_code=US,region_code=CA,city=SANJOSE,dma=807,pmsa=7400,areacode=408,county=SANTACLARA,fips=06085,lat=37.3353,long=-121.8938,timezone=PST,network_type=dialup HTTP_ACCEPT: HTTP_ACCEPT_CHARSET: HTTP_ACCEPT_ENCODING: HTTP_ACCEPT_LANGUAGE: HTTP_CONTENT_LENGTH: 306 HTTP_CONTENT_LOCATION: HTTP_CONTENT_TYPE: text/html; charset=utf-8 HTTP_COOKIE: HTTP_HOST: debug.playground.ets HTTP_REFERER: HTTP_USER_AGENT: QUERY_STRING: REMOTE_ADDR: 127.0.0.1 REQUEST_METHOD: GET REQUEST_PATH: /58f2f1f7cae405374f75bfd6c0ca823f HTTP_DATE: Mon, 16 Jan 2023 12:34:45 GMT HTTP_CONNECTION: close HTTP_X_POWERED_BY: Express HTTP_ETAG: W/"132-SLdxAKAFWKtoTJkqbTN+e04VG9I" [2007]: Line 2. Including fragment "http://10.35.249.181:5012/esi/fragment.html". Warning: [2006]: Line 2. Failed fetching fragment "http://10.35.249.181:5012/esi/fragment.html". Error: [2005]: Your code did not run successfully.

/****End Debugging Section*****/

` I checked the backend server, it's giving **Error: Parse Error: Invalid method encountered** error I tried many things but I could not resolve this issues please suggest what I am doing wrong Backend error: `[Error: Parse Error: Invalid method encountered] { bytesParsed: 267, code: 'HPE_INVALID_METHOD', reason: 'Invalid method encountered', rawPacket: , headerSent: true } GET /esi/Fragment.html HTTP/1.1 Accept: */* Host: 10.35.249.181:5012 Via: 4.0 asi_server X-Akamai-ClientIP: 127.0.0.1 X-Akamai-MD-Component3: 230s X-AKAMAI-FORCE-G2G-AUTH: On Connection: close ` **Docker command** : docker run -ti -p 8088:80 akamaiesi/ets-docker:latest --remote_origin http://10.35.249.181:5012 --debug 10.35.249.181 --geo 10.35.249.181:off --remote_origin 127.0.0.1:5012 --debug localhost --geo localhost:off
sjoulano commented 1 year ago

I've noticed two "--remote_origin" options/flags at your command, one of them is incorrect: --remote_origin http://10.35.249.181:5012/

the flag should look like: --remote_origin - hostname and port to use for an additional remote/upstream origin

dipak7587 commented 1 year ago

Hi @sjoulano ,

I am testing in the local system and I corrected the docker command but its not working docker run -ti -p 8088:80 akamaiesi/ets-docker:latest --remote_origin 10.35.249.181:5012 --debug 10.35.249.181 --geo 10.35.249.181:off --debug localhost --geo localhost:off

10.35.249.181 : local system IP

Server Error: [Error: Parse Error: Invalid method encountered] { bytesParsed: 71, code: 'HPE_INVALID_METHOD', reason: 'Invalid method encountered', rawPacket: <Buffer 47 45 54 20 2f 66 72 61 6d 67 6d 65 6e 74 2e 68 74 6d 6c 20 48 54 54 50 2f 31 2e 31 0d 0a 41 63 63 65 70 74 3a 20 2a 2f 2a 0d 0a 48 6f 73 74 3a 20 31 ... 431 more bytes>, headerSent: true } GET /framgment.html HTTP/1.1 Accept: / Host: 10.35.249.181:5012

Via: 4.0 asi_server

X-Akamai-ClientIP: 127.0.0.1

Cookie: Akamai-UnencDebug=Akamai-ClientIP=127.0.0.1;Akamai-CPDomain=.0.0.1;Akamai-DebugValue=On;Akamai-Expires=999999999

X-Akamai-MD-Component3: 230s</cache:max-age>

X-AKAMAI-FORCE-G2G-AUTH: On

X-Akamai-Debug: Akamai-ClientIP=127.0.0.1;Akamai-CPDomain=.0.0.1;Akamai-DebugValue=On;Akamai-Expires=999999999

Connection: close

Analyze:

  1. Akamai ETS is giving some request headers, between the request headers extra spaces are there, and the server lot is able to parse the request headers.
  2. I put the console log for request headers, it is showing only two headers Accept: / Host: 10.35.249.181:5012
  3. In the above error message is showing bytesParsed error in line number 71 and I am checking what is the data in line number 71 then its showing space (" ").
sjoulano commented 1 year ago

Maybe it is related to the encoding? E.g. bytes to string conversion on your server.