question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bindaddress of meta never work right.

See original GitHub issue

I have multi local IPs with different outgoing port to internet. simply:

        yield scrapy.Request('http://httpbin.org/ip', self.parse3, meta={'bindaddress': ('192.168.0.2', 0)}, dont_filter=True)
        yield scrapy.Request('http://httpbin.org/ip', self.parse3, meta={'bindaddress': ('192.168.0.3', 0)}, dont_filter=True)

responsed same result.

ps: already verified the two bind-address works using curl.

does anyone know how to fix and be willing to fix it?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tarnenokcommented, Jan 14, 2019

@NewUserHa, as @alwaysused mentioned above, twisted caches connections by the key. That key is composed in line and don’t take into account bind address property. So, for the second link in your example it uses cached connection with this meta={'bindaddress': ('192.168.0.2', 0)}

Your example with empty custom_settings works properly, because twisted caches connection in line after http response is received. So If there is no defined DOWNLOAD_DELAY or it’s smaller than a server time response, than the second request starts earlier then connection from the first request is cached. Consequntly it creates a new connection.

To fix this problem you can patch connection key composed in twisted in line to the following

key = (parsedURI.scheme, parsedURI.host, parsedURI.port, endpoint._bindAddress)

But it access the private member and violates incapsulation properties. If this functionality is relly needed by community it worths to think better and maybe update ScrapyAgent to take into account bindAddress.

0reactions
alwaysusedcommented, Jan 5, 2019

sorry for replying so late, that was midnight in my country and i got to sleep. About the debug are you using an ide for python? I’m using pycharm and the library can be found in the project sidebar, and if you are not using this you can google or just search it in the ide’s website.The ‘twisted’ network library is a pure python project instead a c extesion so debugging the library is possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the purpose of bindaddress in scrapy? - Stack Overflow
The bindaddress option can be used to tell Scrapy which one of those local IP addresses should be used as the source address...
Read more >
scp w/ BindAddress - ssh - Super User
I have a server on my local network but am connected to a VPN, and to reach the local server via ssh on...
Read more >
How bad is setting MySQL's bind-address to 0.0.0.0?
I think you are misunderstanding the bind-address setting a little. These are the local addresses that MySQL will listen for connections.
Read more >
Mysql enable remote connection in centos,my.cnf does not ...
I'm reading this article that says I should comment out bind-address but bind address is not available in the my.conf , this line...
Read more >
MariaDB bind-address not updating? - Ask Ubuntu
So, it turns out I was editing the wrong configuration file. After running strace mysqld --print-defaults I found it opening a different ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found