Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I host a website with a game client that uses TCP for connections. I am currently looking for a way to proxy my connections from one server to my origin server. I have tested Iptables forwarding and I have found that whilst it works HaProxy seems to perform better. The problem I'm facing is HaProxy randomly disconnects users after a random time of their connection being open. It's often less than 2 minutes. I'm quite new to Linux and of course I am a novice to haProxy.

Here my configuration, the origin IP address has been removed for obvious reasons:

maxconn 1000

    mode tcp
    timeout connect 5000ms
    timeout client 5000ms
    timeout server 5000ms

frontend proxy-in
    mode tcp
    bind *:1233
    default_backend proxy-out

backend proxy-out
    mode tcp
    server s1

listen admin
    bind *:7772
    stats enable

Thank you. More details can be provided (if needed).

share|improve this question
There's not much to go on without haproxy's log file; enable logging and you may find the reason. – sendmoreinfo Jun 16 '13 at 19:58

Depending on how your gaming server works, you'll probably need to work with your timeout client and your timeout server. These are currently set to 5 seconds in your configuration.

These settings relate to your tcp session. If you want to balance things a little better to your servers you may also want to look at persistence profiles to balance certain connection to the same servers. Again it really depends on your configuration.

Also look at the balance option to look through docs.

Example algorithm in haproxy docs: (

leastconn   The server with the lowest number of connections receives the
            connection. Round-robin is performed within groups of servers
            of the same load to ensure that all servers will be used. Use
            of this algorithm is recommended where very long sessions are
            expected, such as LDAP, SQL, TSE, etc... but is not very well
            suited for protocols using short sessions such as HTTP. This
            algorithm is dynamic, which means that server weights may be
            adjusted on the fly for slow starts for instance.

May also need tcp keep alive setup: (

You can also actively view your sessions with a great tool call haproxyctl which you can find on github or install with gem install haproxyctl.

> haproxyctl show sess

0x1eb23c0: proto=tcpv4 src= fe=https be=<NONE> srv=<none> ts=08 age=1m36s calls=40 rq[f=400000h,i=0,an=1ch,rx=1m23s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=2,ex=] s1=[0,0h,fd=-1,ex=] exp=1m23s
0x1e3b170: proto=tcpv4 src= fe=https be=<NONE> srv=<none> ts=08 age=1m36s calls=31 rq[f=400000h,i=0,an=1ch,rx=1m23s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=3,ex=] s1=[0,0h,fd=-1,ex=] exp=1m23s
0x1e35da0: proto=tcpv4 src= fe=https be=<NONE> srv=<none> ts=08 age=1m36s calls=35 rq[f=400000h,i=0,an=1ch,rx=1m23s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=8,ex=] s1=[0,0h,fd=-1,ex=] exp=1m23s
0x1e4fa50: proto=tcpv4 src= fe=https be=<NONE> srv=<none> ts=08 age=1m36s calls=15 rq[f=400000h,i=0,an=1ch,rx=1m23s,wx=,ax=] rp[f=008000h,i=0,an=00h,rx=,wx=,ax=] s0=[7,8h,fd=9,ex=] s1=[0,0h,fd=-1,ex=] exp=1m23s
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.