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

[ENH] Use socket keepalived instead of original #4

Open
leungigi opened this issue Mar 11, 2019 · 0 comments
Open

[ENH] Use socket keepalived instead of original #4

leungigi opened this issue Mar 11, 2019 · 0 comments

Comments

@leungigi
Copy link

Scenarios:

Sometimes, enduser need to run longterm traffic (more than 2 hours), and ixia client socket will idle after send out traffic, some network gateway or linux server maybe close ixia client socket due to no any response during that time, then script will crash due to socket closed.

Solution:

Use "setsockopt" to set socket as keepalived, detail pls refer Python socket.TCP_KEEPINTVL() Examples

Code change as below:

def connect(self):
        log.debug('Opening connection to %s:%d', self.host, self.port)
        fd = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        fd.connect((self.host, self.port))
        self.fd = fd
        self.set_socket_keepalive 
        self.call('package req IxTclHal')

def set_socket_keepalive(self):
        self.fd.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
        self.fd.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 1)
        self.fd.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, 60)
        self.fd.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, 5)
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