Rob--W / cors-anywhere

CORS Anywhere is a NodeJS reverse proxy which adds CORS headers to the proxied request.
MIT License
8.65k stars 6.07k forks source link

Not found because of proxy error: Error: socket hang up #94

Closed jromerob closed 6 years ago

jromerob commented 6 years ago

I'm trying to get indications of a walk route quering the Cartociudad service. The service url is ok and responds with a JSON with all the indications.

Testing the service URL in my navigator the result is ok but in my Angular app when i try http.get("http://127.0.0.1:8123/http://www.cartociudad.es/services/api/route?orig=40.44184877149766,-3.5748567877248845&dest=41.36999441400242,2.1469160601647803&locale=es&vehicle=WALK") the result is a 404 NOT FOUND. Response._body is "Not found because of proxy error: Error: socket hang up"

Trying with other proxy the result is OK. Any ideas ?

Thanks.

Current proxy.js var host = process.env.PORT ? '0.0.0.0' : '127.0.0.1'; var port = process.env.PORT || 8123;

var cors_proxy = require('cors-anywhere'); cors_proxy.createServer({ originWhitelist: [], // permite todos los orígenes requireHeader: [], removeHeaders: ['cookie', 'cookie2'], setHeaders : { "x-powered-by": "CORS Anywhere" } }).listen(port, host, function() { console.log('Ejecutando proxy en ' + host + ':' + port); });

System INFO | request http://www.cartociudad.es/services/api/route?orig=40.44184877149766,-3.5748567877248845&dest=41.36999441400242,2.1469160601647803&locale=es&vehicle=WALK | node 6.11.1 | npm 3.10.10 | Operating System Windows 10

Rob--W commented 6 years ago

Trying with other proxy the result is OK.

Is this proxy also running on localhost?

jromerob commented 6 years ago

Yes, the proxy is on localhost (127.0.0.1:8123).

This is the Chrome console output:

image

Rob--W commented 6 years ago

Not CORS Anywhere, the other proxy that is working according to you. I am asking in order to determine whether the issue is specific to CORS Anywhere, or specific to your local setup (e.g. your IP is blocked by that other site, or your firewall has blocked outbound connections).

jromerob commented 6 years ago

Oh, sorry !. No, the other proxy isn't on localhost. But CORS Anywhere is working ok in other request in the same app. the error occurs only in that request.

This is a right request made by the same app throught CORS anywhere running at localhost image

Rob--W commented 6 years ago

When you use another program to send the request to the destination, with the same request headers (e.g. curl), does the request succeed?

jromerob commented 6 years ago

Curl works right:

curl "http://127.0.0.1:8123/http://www.cartociudad.es/services/api/route?orig=40.44184877149766,-3.5748567877248845&dest=41.36999441400242,2.1469160601647803&locale=es&vehicle=WALK"

Response (excerpt) {"bbox":["-3.5749393551147315","40.43971781670417","2.1488940823576024","41.67141336958289"],"distance":"601785.5022296584","found":"true","from":"40.44184877149766,-3.5748567877248845","geom":"uxyuFjfyTg@SOEMIMKIMKWEQESCOGUAK@MDIn@?T?|BJlBHVCVEDCLKJOFQF_@Dm@BwBJyCD}BHcC\gQFiCBgCHwA@_A@eTNiIHqC@IOeGSoBU{BcAkEqBmFyC{JaAyEi@{Da@yDUwDQmHHkCNqCf@yINkECwBWuDWiBQeAKu@_AaFk@}BkAeFq@cCqCaKo@cCi@cCa@kAq@{AIKSQGEaAuAS]MOKGMGOE]EICMEEEIKAEACYq@CAa@iCm@_EYcBaAgG{A_Im@mDqA}HCG}H{]cBqH?GUiBEe@IcAK}AOaDEs@AOZBKoA@uDGi@E[MSc@{@u@s@aAo@s@gASq@M{BGmAOgD?c@M]Es@WgFQeCAME}@Eu@YgFQ_Ey@oPQ_Em@uLo@}MYcGIcBIaBGwAGuAEk@MmCKoBMoCWgFMWBy@KgAU{EIqAK}BUkHG]CWEy@OiDAOEs@GCEECEAGAC?E@G?C@GDE@ACcAEkAMoDUkFMkCECCCACCE?CE{@?E@EBI?G?IOyA?QE[KYAEeAmEi@iDWqBUaBKuA?QDyAe@eB[kB}@oHaAiHMgAAEAEACCCAAM}Ak@wEWoBBE?C?EACCECCC?C?_AgHkAeJs@iGIQ@C?GAEACAk@{@wGkAcJm@aFGg@Mu@KkACe@@]?M?G?ICGACEIMc@WwAu@qGm@iEMq@@E?G?G?EAGAECECCq@eEE[i@aEQ}A_@_DMw@UeA]wA?IAKEKEE]qAiC_Js@iBAE{BsIy@kD_@{AMy@O[Ko@Ag@SeAO_@IS_BoIs@mDMo@Q{@COUiAm@uCu@mDsCkOwAgH[oBO_AMcB?qDDeGBuDF_HBmDHaNAqBSiBW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C{Eg@_A}@qB_BoDYu@gBaEe@}@[}@Y]MMKIy@a@QISQKOUYKMOWk@_AgByCcDiF}@sAm@_AqA

jromerob commented 6 years ago

More info:

`curl -v "127.0.0.1:8123/http://www.cartociudad.es/services/api/route?orig=43.1514858477619,-4.0472363927932&dest=40.44184877149766,-3.5748567877248845&locale=es&vehicle=WALK"
STATE: INIT => CONNECT handle 0x20081ad8; line 1407 (connection #-5000)
Added connection 0. The cache now contains 1 members
Trying 127.0.0.1...
TCP_NODELAY set
STATE: CONNECT => WAITCONNECT handle 0x20081ad8; line 1460 (connection #0)
Connected to 127.0.0.1 (127.0.0.1) port 8123 (#0)
STATE: WAITCONNECT => SENDPROTOCONNECT handle 0x20081ad8; line 1567 (connection #0)
Marked for [keep alive]: HTTP default
STATE: SENDPROTOCONNECT => DO handle 0x20081ad8; line 1585 (connection #0)
GET /http://www.cartociudad.es/services/api/route?orig=43.1514858477619,-4.0472363927932&dest=40.44184877149766,-3.5748567877248845&locale=es&vehicle=WALK HTTP/1.1
Host: 127.0.0.1:8123
User-Agent: curl/7.51.0
Accept: /

STATE: DO => DO_DONE handle 0x20081ad8; line 1664 (connection #0)
STATE: DO_DONE => WAITPERFORM handle 0x20081ad8; line 1791 (connection #0)
STATE: WAITPERFORM => PERFORM handle 0x20081ad8; line 1801 (connection #0)
HTTP 1.1 or later with persistent connection, pipelining supported
HTTP/1.1 200 OK
x-request-url: http://www.cartociudad.es/services/api/route?orig=43.1514858477619,-4.0472363927932&dest=40.44184877149766,-3.5748567877248845&locale=es&vehicle=WALK
Server Apache-Coyote/1.1 is not blacklisted
server: Apache-Coyote/1.1
content-type: application/json
transfer-encoding: chunked
date: Thu, 09 Nov 2017 09:35:47 GMT
Marked for [closure]: Connection: close used
connection: close
x-final-url: http://www.cartociudad.es/services/api/route?orig=43.1514858477619,-4.0472363927932&dest=40.44184877149766,-3.5748567877248845&locale=es&vehicle=WALK
access-control-allow-origin: *
access-control-expose-headers: server,content-type,transfer-encoding,date,connection,x-final-url,access-control-allow-origin

bbox":["-4.153689089872445","40.44187308607131","-3.5741682031937287","43.152457508872246"],"distance":"353022.13238046836","found":"true","from":"43.1514858477619,-4.0472363927932","geom":"yekfGpcuWRm@f@qATo@Ja@n@gAPaACcBn@MfCu@VKRUb@ e@tC@@Gf@KFAA]ZA~DGZCTKpDsBzA}@KGbDiBl@YVIv@S\OLGLWVQHINERCT@bALATl@AvCV@C|@IdA@hAT@TX@Rh@Ll@DjAHj@LJl@h@NPJEPMVSBPLhALAH^JZVz@LZLZr@hA|@bAp@l@r@h@~@f@|B|@zDv@dARj@Hd@BF@~@XAb@fB~@d@\x@r@dApALT\p@JVPVJVLTL^JVNZLTLVZn@PT^j@P TNVp@ANRNVZd@T\\j@fAJVLXf@lANVZp@HXj@fAHPBDd@f@b@b@f@\\RNTJRJz@f@C~@pAr@x@l@hAfARPPTNT@f@NZPTJT@f@lAtBp@rANVJNPRJLNFJHEBVLVDTD\DVHTDj@T~@Xn@?xAOf@Wh@]dAoA@e@ROPSd@a@LSlA}@bAWj@AbAN~@^@JV?ASAYROPSTq@B[A@?@A]?@@@J{@Tu@L[Zm@ g@ROTIbAQj@?l@Bj@Lj@PRLTHfBnA|@d@TBV?AWj@IV?TDTHb@@t@x@RNj@Vh@VRPB@NLPRB@r@p@h@VTHvAb@f@ZPR^j@NVJXTt@LZJV@j@PFzA^RHTNj@NTHj@VRFj@TAZRLTJRNRHRJvAj@RLTJpAp@RRb@d@LVJZXn@NV\p@NRPT^l@n@ANVNV^j@n@fAJVHZD\\@^H\\JVNTRNTLTJ|@f@THRFn@@bAKl TIRKTMz@g@~@e@tCqATI@CH?TBd@NdAb@RLv@v@AzAJJxDpD\\Vh@PfCLXFTHl@d@b@n@Zz@H@Db@XtBDPDPFLTXXPZBn@Eh@?b@H@ZZb@Pj@Jp@@ZCZ@ZDZHXJVNRPLPHTBT?z@Ud@Eh@@d@Hv@b@hC~C\\VTHTB~BAb@Bj@Pp@@lAnBAtAVTZJZARGbBmARE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v@p@dAbATRb@j@\h@RXVb@DH|AdC@|@x@BJVPZL\x@nBJ\Rh@d@vAN^Pj@@vAPt@J@XnAR~@FVNn@v@jDVbADP@HH^b@hBV~@JXb@tAl@|A^t@JXr@pAt@hAXh@bAxAHH\d@jAdBh@~@b@r@Xf@T@Vf@|@f ApB^~@Zv@JXJ^HP\\hAN@HT@@FP~AlFn@fB@hAJ^Vx@f@lA^x@b@l@JL^@PJRPf@ZLDFB@NPBv@HR@V?\\BrA?XCj@ATARAP?h@EZCv@Gn@I^ElAQPEf@KASVCzAa@bGcC~BmAbCsAxBuAjBeBtAcBvBaCpByBjAoANQfCwCtBkBpBeBtBuB|BmAlCa@z@FZHTHlA\bCpApCx@bAFDEl@CRARCZEf@KZK|@]j

jromerob commented 6 years ago

Hi i think i found the problem:

I'm loading the app on localhost and the proxy on 127.0.0.1, in this case fails the request image

if load the app over 127.0.0.1 the request works !! image

jromerob commented 6 years ago

More info: Changing my configuration to use localhost in request and proxy.js to run CORS Anywhere on localhost (not 127.0.0.1 ) didn´t work: image

Rob--W commented 6 years ago

Is localhost resolving to 127.0.0.1 ?

jromerob commented 6 years ago

Yes El 11/11/2017 02:24, "Rob Wu" notifications@github.com escribió:

Is localhost resolving to 127.0.0.1 ?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/Rob--W/cors-anywhere/issues/94#issuecomment-343628649, or mute the thread https://github.com/notifications/unsubscribe-auth/ALUVSN7rlPjJYtmVil77jDI87s7lwPjdks5s1PdhgaJpZM4QWT_0 .

Rob--W commented 6 years ago

Curl works right:

Can you use exactly the same curl command as the browser (in the devtools you can right-click on a request row and click to copy as a curl command). Then repeatedly issue the request and remove headers at each step until you found which request header results in a difference of how a request is handled.