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

Is there a way to get the ephemeral local port of the axios request? #4122

Closed
kevgrig opened this issue Oct 1, 2021 · 1 comment
Closed

Comments

@kevgrig
Copy link

kevgrig commented Oct 1, 2021

Describe the issue

Thank you for axios; I use it in a React Native app particularly for onUploadProgress which works great.
However, as part of debugging issues, it would be really nice if there was a way to get the request's local ephemeral port so that I can print it to debug logs. This can then help directly find a TCP stream in a tcpdump. Is there any way to get this in axios or are there other libraries you'd recommend (that also have something like onUploadProgress)? Thanks!

Example of what I'd like in the onContextInfo callback:

const res = await axios({
  method: "POST",
  url: "https://example.com/upload",
  onContextInfo: (contextInfo) => {
    console.log("local port: " + contextInfo.localPort);
    // Ideally, it'd also be great to have the local IP address here if available, and also remote
    // host and port, even though we'll generally know that ahead of time, but it'll make it easier
    // to make a generic onContextInfo callback logger.
  },
  onUploadProgress: (progressEvent) => {
    console.log("onUploadProgress: " + Math.round( (progressEvent.loaded * 100) / progressEvent.total ));
  },
  timeout: 60000,
});
@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2021

Hello! 👋

This issue is being automatically closed because it does not follow the issue template. Please read the issue template carefully and follow all of the instructions when opening a new issue.

Thanks

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

1 participant