Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search Example returning an Error: maximum redirect limit exceeded #53

Open
mbmcmullen27 opened this issue Mar 30, 2021 · 5 comments
Open
Assignees

Comments

@mbmcmullen27
Copy link

Running the #search example in the README returns an error for too many redirects.
Tried adjusting the city and the search query but the redirect limit error is always returned.

reproduced in node versions:
v15.12.0
v14.16.0

var
  craigslist = require('node-craigslist'),
  client = new craigslist.Client({
    city : 'seattle'
  });

client
  .search('xbox one')
  .then((listings) => {
    // play with listings here...
    listings.forEach((listing) => console.log(listing));
  })
  .catch((err) => {
    console.error(err);
  });

throws:

Error: maximum redirect limit exceeded
    at ClientRequest.<anonymous> (/mnt/c/Users/mbmcm/example/node_modules/reqlib/dist/index.js:429:29)
    at Object.onceWrapper (node:events:476:26)
    at ClientRequest.emit (node:events:369:20)
    at HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:636:27)
    at HTTPParser.parserOnHeadersComplete (node:_http_common:129:17)
    at Socket.socketOnData (node:_http_client:502:22)
    at Socket.emit (node:events:369:20)
    at addChunk (node:internal/streams/readable:313:12)
    at readableAddChunk (node:internal/streams/readable:288:9)
    at Socket.Readable.push (node:internal/streams/readable:227:10) {
  options: {
    hostname: 'seattle.craigslist.org',
    method: 'GET',
    path: '/',
    maxRedirectCount: 5,
    maxRetryCount: 3,
    timeout: 60000,
    headers: { 'Content-Type': 'application/json', 'Content-Length': 0 },
    [Symbol(context)]: URLContext {
      flags: 400,
      scheme: 'https:',
      username: '',
      password: '',
      host: 'seattle.craigslist.org',
      port: null,
      path: [Array],
      query: null,
      fragment: null
    },
    [Symbol(query)]: URLSearchParams {}
  },
  state: {
    data: '',
    failover: { index: 0, values: [] },
    redirects: [ [URL], [URL], [URL], [URL], [URL] ],
    tries: 1,
    headers: { location: 'https://seattle.craigslist.org/' },
    statusCode: 301
  }
}

the redirects:

[
  URL {
    href: 'https://seattle.craigslist.org/search/sss?sort=rel&query=xbox%20one',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/search/sss',
    search: '?sort=rel&query=xbox%20one',
    searchParams: URLSearchParams { 'sort' => 'rel', 'query' => 'xbox one' },
    hash: ''
  },
  URL {
    href: 'https://seattle.craigslist.org/',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  },
  URL {
    href: 'https://seattle.craigslist.org/',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  },
  URL {
    href: 'https://seattle.craigslist.org/',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  },
  URL {
    href: 'https://seattle.craigslist.org/',
    origin: 'https://seattle.craigslist.org',
    protocol: 'https:',
    username: '',
    password: '',
    host: 'seattle.craigslist.org',
    hostname: 'seattle.craigslist.org',
    port: '',
    pathname: '/',
    search: '',
    searchParams: URLSearchParams {},
    hash: ''
  }
]
@eajr
Copy link

eajr commented Apr 28, 2021

I am getting the same result as well on node v16.0.0

@amirmursal
Copy link

I am having the same issue. Please resolve this

@3h50
Copy link

3h50 commented Aug 14, 2021

Can confirm.

@dylan-albertazzi
Copy link

I am also running into this.

@pcbailey
Copy link

pcbailey commented Feb 3, 2022

I'm also hitting this problem.

@brozeph brozeph self-assigned this Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants