Thanks to visit codestin.com
Credit goes to github.com

Skip to content

SocketService: set socket operation timeout before connecting#5911

Merged
ilyam8 merged 4 commits into
netdata:masterfrom
ilyam8:socket_timeout_fix
Apr 25, 2019
Merged

SocketService: set socket operation timeout before connecting#5911
ilyam8 merged 4 commits into
netdata:masterfrom
ilyam8:socket_timeout_fix

Conversation

@ilyam8

@ilyam8 ilyam8 commented Apr 24, 2019

Copy link
Copy Markdown
Member
Summary

Fixes: #5541

This PR:

  • removes setblocking calls
    def setblocking(self, v):
        if v:
            self.settimeout(None)
        else:
            self.settimeout(0.0)
  • sets socket timeout before call to connect

  • adds separate connect, read and write timeouts. Default is 2 seconds for all.

socket.settimeout(value)
Set a timeout on blocking socket operations. The value argument can be a nonnegative float expressing seconds, or None. If a float is given, subsequent socket operations will raise a timeout exception if the timeout period value has elapsed before the operation has completed. Setting a timeout of None disables timeouts on socket operations. s.settimeout(0.0) is equivalent to s.setblocking(0); s.settimeout(None) is equivalent to s.setblocking(1).

Component Name

/collectors/python.d.plugin/python_modules/bases/FrameworkServices/SocketService

Additional Information

@ilyam8

ilyam8 commented Apr 24, 2019

Copy link
Copy Markdown
Member Author

@Steve8291

i think this PR fixes your problem, please test it!

@netdatabot netdatabot added area/collectors Everything related to data collection area/external/python labels Apr 24, 2019
@ilyam8 ilyam8 merged commit 339d334 into netdata:master Apr 25, 2019
@Steve8291

Copy link
Copy Markdown
Contributor

@ilyam8
Here is a new link to the paste if you still want to see it.
https://pastebin.com/hmR40rLz
I don't know why the other one didn't work.
I'm also not sure how to test a pull request. Do I just make the code changes directly or do I have to compile netdata on my machine or something like that? Sorry for my lack of knowledge here.
Looks like the PR was committed into "master" So can I just run an update to get it?

@ilyam8

ilyam8 commented Apr 25, 2019

Copy link
Copy Markdown
Member Author

Looks like the PR was committed into "master" So can I just run an update to get it?

Yes.

connecting socket to "::1", port XXXX

Will hang only for 2 seconds there.

@Steve8291

Copy link
Copy Markdown
Contributor

@ilyam8
Thanks for fixing this. All my charts are coming up much faster now after a restart or a reload of netdata. I'm currently running: v1.14.0-11-nightly that has the patch applied.

@ilyam8

ilyam8 commented Apr 26, 2019

Copy link
Copy Markdown
Member Author

@Steve8291 it seems you have configured ip6tables with DROP target as default.

@Steve8291

Copy link
Copy Markdown
Contributor

@ilyam8
I that a problem?
I do have all ipv6table chains set to DROP temporarily until I can get around to writing more specific rules. Is it the OUTPUT Chain that needs set to ACCEPT?

@ilyam8

ilyam8 commented Apr 26, 2019

Copy link
Copy Markdown
Member Author

I that a problem?

Ye, i suggest to change default policy to REJECT for INPUT chain.

@ilyam8 ilyam8 deleted the socket_timeout_fix branch April 27, 2019 18:40
jackyhuang85 pushed a commit to jackyhuang85/netdata that referenced this pull request Jan 1, 2020
…a#5911)

* set socket operation timeout before connecting

* add connect, read, write timeouts

* remove .setblocking calls

* set default timeouts to 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/collectors Everything related to data collection

Projects

None yet

Development

Successfully merging this pull request may close these issues.

python SocketService: lack of connect timeout, python.d.plugin hangs

4 participants