simple-proxy-agent icon indicating copy to clipboard operation
simple-proxy-agent copied to clipboard

Mysterious 421 Misdirected Request Error

Open restyler opened this issue 5 years ago • 1 comments

I'm getting weird 421 error and I think it's related to simple proxy agent since after switching agent to https://github.com/TooTallNate/node-proxy-agent exact same code works fine.

image

Only certain webservers produce this error (github is one of them), I guess it has something to do with HTTP2 and/or SNI.

I've tried to debug it via tcpdump but I don't see any major differences between two agents in protocol..

Steps to reproduce:


const fetch = require('node-fetch')
const ProxyAgent = require('simple-proxy-agent')

const TSProxyAgent = require('https-proxy-agent');




url = 'https://raw.githubusercontent.com/imakewebthings/waypoints/master/licenses.txt'

addrProxy2 = "http://any-proxy-http-or-socks"

let agent = ProxyAgent(addrProxy2)



console.log ('421 redirect err')
fetch(url, {agent})
.then(async (resp) => {
    console.log(resp)
})
.catch(err => {
    console.error(err)
})
.finally(() => {


    let agent2 = TSProxyAgent(addrProxy2)

    console.log('200 OK with tootallnate agent:')
    fetch(url, {agent: agent2})
    .then(async (resp) => {
        console.log(resp)
    })
    .catch(err => {
        console.error(err)
    })

})



restyler avatar Oct 16 '20 11:10 restyler

Thank you for reporting, i can't quite spot the problem yet. Gonna have to dig a bit deeper. 😄

zjael avatar Oct 18 '20 12:10 zjael