Haproxy "remote host forced to shut down an existing connection" error and resolution

Source: Internet
Author: User
Tags sql client keep alive haproxy

Use Haproxy as the load balancer for SQL Server.

The sample configuration items in the document are used:

Timeout client 50s
Timeout server 50s

With this configuration item, there are sometimes "remote hosts forcing an existing connection to shut down" error.

The reason for this error is that once the SQL client does not send data to haproxy for more than 50s, Haproxy will close the connection, and the SQL client will send the data with an exception when it thinks the connection is still in flux.

After reviewing the official documentation for Haproxy, as well as the documentation for MySQL and SQL Server, change the configuration to:

Timeout Client 8h
Timeout Server 8h

Then it's normal. Why is it set to 8 hours? SQL Server did not find a similar wait timeout data, so borrowed from the MySQL configuration item, MySQL has a configuration named wait timeout, its default time is 8 hours, This configuration item means that when MySQL discovers that the TCP connection with the client is inactive for more than 8 hours (sending and receiving data), then MySQL shuts down the connection. This configuration is similar to the keep alive timeout in http1.1.

Reference:

apache:keep-alive Timeout

Amount of time the server would wait for subsequent requests on a persistent connection

Mysql:wait_timeout

The number of seconds the server waits for activity in an interactive connection before closing it.

haproxy:timeout Client

The inactivity timeout applies when the client was expected to acknowledge or send data.

Haproxy "remote host forced to shut down an existing connection" error and resolution

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.