Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8945657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T12:17:57+00:00 2026-06-15T12:17:57+00:00

I’m running the following code… using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings[db-connection].ConnectionString)) { connection.Open(); var

  • 0

I’m running the following code…

using (var connection = new SqlConnection(ConfigurationManager.ConnectionStrings["db-connection"].ConnectionString))
{
    connection.Open();
    var command = new SqlCommand("SELECT @@SERVERNAME",connection);

    using (var reader = command.ExecuteReader())
    {
        reader.Read();
        return reader[0].ToString();
    }
}

…as a sanity check to return the name of the DB server this application is pointing to. There are two DB servers (DB00 and DB01) and they are behind HAProxy which is setup to failover to DB01 if DB00 is unavailable.

The connection string looks like this:

    <add name="db-connection"
connectionString="User Id=USER_ID; Password=PASSWORD; Initial Catalog=the-database; Server=load-balancer.is.here,59281; Application Name=My.Application.Name;Min Pool Size=5;Max Pool Size=500;Connect Timeout=10;Connection Lifetime=29;" />

The problem we’re experiencing is this:

  • we failover to DB01 (currently done by editing the HAProxy config, making DB00 the backup and then reloading HAProxy)
  • the SELECT code (the code at the begining of this question) should now return DB01 as the servername but it doesn’t, it still returns DB00
  • this means our SQLConnections still seem to be pointing to the wrong DB
  • the problem persists until we restart the mono process on the box the code is hosted
  • now the sanity check code returns the correct servername – DB01

Any ideas what this could be? Is it possibly a mono connection pooling issue?

EDIT
HAProxy config as requested:

1 global
2         maxconn 4096
3         daemon
4 
5 defaults
6         mode tcp
7         #mode http
8         contimeout      5000
9         clitimeout      50000
10         srvtimeout      50000
11 
12 
13 frontend blahblah
14         bind *:59283
15         mode tcp
16         default_backend sql-server-lockertest
17 
18 backend sql-server-lockertest
19         balance roundrobin
20         server james 10.0.10.217:1433 check maxconn 32 rise 3 fall 3 
21         server andres 10.0.10.226:1433 check maxconn 32 rise 3 fall 3 backup

Regards,

James

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T12:17:59+00:00Added an answer on June 15, 2026 at 12:17 pm

    It turns out Mono didn’t support yet the “Connection Lifetime” parameter in connection strings.

    But we just fixed it and proposed a pull request:

    https://github.com/mono/mono/pull/517

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.