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 7884255
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:45:00+00:00 2026-06-03T04:45:00+00:00

i’m creating a C# Server, that opens a named pipe and collects data that

  • 0

i’m creating a C# Server, that opens a named pipe and collects data that clients send to it. Basically, i’m storing the collected information in a mysql database, using .NET MySql Connector and the MySqlConnection Class. I also added a fallback rule, which in case the DB is out of reach, buffers the info sent by the clients in an SQL file and imports it into the DB when it is available again.
Everything works fine, except when the DB is gone completely (for example when the server that runs the DB is not on the network anymore because it crashed), the Connect() Method takes forever to throw an exception. This is unacceptable, because the clients send in A LOT of data. Is there any way to fix this? If the query fails because a table is not there or something like that, it returns an error immediately.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using log4net;
using MySql.Data.MySqlClient;

namespace PipeServer
{
    class MySqlConnector
    {
        //register logger
        private static readonly ILog log = LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);

        public delegate void MessageReceivedHandler(string message);
        public event MessageReceivedHandler MessageReceived;

        private string host;
        private string database;
        private string user;
        private string password;
        private MySqlConnection connection;
        private List<string> rows = new List<string>();



        public MySqlConnector()
        {
            this.host = Settings.Default.db_host;
            this.database = Settings.Default.db_schema;
            this.user = Settings.Default.db_user;
            this.password = Settings.Default.db_pw;
            string myConnectionString = "SERVER=" + this.host + ";" +
                        "DATABASE=" + this.database + ";" +
                        "UID=" + this.user + ";" +
                        "PASSWORD=" + this.password + ";";

            connection = new MySqlConnection(myConnectionString);




        }

        public bool Connect()
        {
            if (connection.State != System.Data.ConnectionState.Open)
            {
                try
                {
                    connection.Open();
                    this.MessageReceived("Connected to Database");
                    return true;
                }
                catch (MySqlException ex)
                {
                    log.Error("failed to connect! mysql error: " + ex);
                    this.MessageReceived("No Database connection - Error: "+ex);
                    return false;
                }

            }
            else
            {
                this.MessageReceived("Connected to Database");
                return true;
            }

        }
        .
        .
        .
    }
}

Any hint is highly appreciated!Thanks in advance!

  • 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-03T04:45:01+00:00Added an answer on June 3, 2026 at 4:45 am

    When you mean forever you mean something like 30s ?

    You’re probably looking for adding TimeOut setting into the ConnectionString.

    http://www.connectionstrings.com/mysql

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
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
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
I need a function that will clean a strings' special characters. I do NOT
I want to construct a data frame in an Rcpp function, but when I

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.