Skip to content

Mysterious 421 Misdirected Request Error #24

@restyler

Description

@restyler

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)
    })

})

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions