Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

http.get fails on Android and FreeBSD #8540

Closed
@javihernandez

Description

@javihernandez

Hi,

when making a simple http request I'm getting the following error:

Error: getaddrinfo EAI_BADFLAGS
    at Object.exports._errnoException (util.js:742:11)
    at errnoException (dns.js:46:15)
    at Object.onlookup [as oncomplete] (dns.js:91:26)

Did a few tests and tried to follow the error through the code, but at this point all I can say is that I'm lost. Any ideas? As usually, I'll be happy to help on fixing this.

Resulting object from calling http.get can be found here

Activity

brendanashworth

brendanashworth commented on Oct 15, 2014

@brendanashworth

What code are you running that gives you this error?

javihernandez

javihernandez commented on Oct 15, 2014

@javihernandez
Author

@brendanashworth,

I'm running:

  • Node v0.13.0-pre
  • Built against android-ndk-r9d

I'm just making a simple http request, something like:

http.get("www.google.com", function(a,b,c) {});

Hope this answers to your question.

Also, I checked if cares.getaddrinfo was failing but it's not. It seems to be a problem elsewhere but I'm not experienced enough to diagnose the offending code. :/

brendanashworth

brendanashworth commented on Oct 16, 2014

@brendanashworth

Some suggestions of mine:

  • There isn't a node v0.13.0-pre, do you mean another version?
  • Supply the protocol in the request, i.e.:
https.get('https://google.com', function() {});

Note the use of https, not http as Google redirects to https anyways.

javihernandez

javihernandez commented on Oct 16, 2014

@javihernandez
Author

@brendanashworth,

$ ./node --version v0.13.0-pre

I previously tried with https, same problem.

misterdjules

misterdjules commented on Oct 16, 2014

@misterdjules

@javihernandez Could you please try with a build from the v0.12 branch? Some fixes that are in this branch have not yet been ported to master.

Also, your issue seems like Node.js doesn't pass the right flags to getaddrinfo, or that the flags it passes are not supported on your platform. Could you please tell us what flags are supported by Android for getaddrinfo?

self-assigned this
on Oct 16, 2014
hertzg

hertzg commented on Oct 17, 2014

@hertzg
javihernandez

javihernandez commented on Oct 17, 2014

@javihernandez
Author

thanks for commenting :)

@hertzg, nope, real device

@misterdjules, good point.
Switched to 0.12 branch, fixed a v8-related build error (perhaps it's worth to be reported) and finally got it building well, BUT, still getting the same error.
So yes, seems to be a problem with getaddrinfo's flags. I'll try to find out which flags are supported.

misterdjules

misterdjules commented on Nov 14, 2014

@misterdjules

@javihernandez Did you have some time to investigate what getaddrinfo flags are supported on Android?

javihernandez

javihernandez commented on Nov 14, 2014

@javihernandez
Author

Hey @misterdjules,

not really (been quite busy at work), but a quick search gave me the following:

/*
 * Flag values for getaddrinfo()
 */
#define AI_PASSIVE      0x00000001 /* get address to use bind() */
#define AI_CANONNAME    0x00000002 /* fill ai_canonname */
#define AI_NUMERICHOST  0x00000004 /* prevent host name resolution */
#define AI_NUMERICSERV  0x00000008 /* prevent service name resolution */

and just below we can see ...

/* valid flags for addrinfo (not a standard def, apps should not use it) */
#define AI_MASK \
    (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_NUMERICSERV | \
    AI_ADDRCONFIG)
#define AI_ALL          0x00000100 /* IPv6 and IPv4-mapped (with AI_V4MAPPED) */
#define AI_V4MAPPED_CFG 0x00000200 /* accept IPv4-mapped if kernel supports */
#define AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
#define AI_V4MAPPED     0x00000800 /* accept IPv4-mapped IPv6 address */

Any hint about how/where this should be addressed?

javihernandez

javihernandez commented on Dec 3, 2014

@javihernandez
Author

up

josser

josser commented on Feb 11, 2015

@josser

Very similar issue on freebsd 10:

events.js:85
      throw er; // Unhandled 'error' event
            ^
Error: getaddrinfo EAI_BADFLAGS
    at Object.exports._errnoException (util.js:746:11)
    at errnoException (dns.js:49:15)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:94:26)

Code:

http = require('http');
http.get("www.google.com", function(a,b,c) {}); 

man 3 getaddrinfo https://gist.github.com/josser/ccad69a7c767aa0d3159

node --version
v0.12.0

josser

josser commented on Feb 11, 2015

@josser

Also, I don't have such error on OS X, but it have a bit more extended list of AI_FLAGS:
Additional flags which I found in os x but didn't find in freebsd:

AI_ALL If the AI_ALL bit is set with the AI_V4MAPPED bit, then getaddrinfo() shall return all matching IPv6 and IPv4 addresses. The AI_ALL bit without the AI_V4MAPPED bit is ignored.

AI_V4MAPPED If the AI_V4MAPPED flag is specified along with an ai_family of AF_INET6, then getaddrinfo() shall return IPv4-mapped IPv6 addresses on finding no matching IPv6 addresses ( ai_addrlen shall be 16). The AI_V4MAPPED flag shall be ignored unless ai_family equals AF_INET6.

52 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

    Development

    No branches or pull requests

      Participants

      @josser@pct@piscisaureus@indutny@bnoordhuis

      Issue actions

        http.get fails on Android and FreeBSD · Issue #8540 · nodejs/node-v0.x-archive