powered by simpleCommunicator - 2.0.55     © 2025 Programmizd 02
Целевая тема:
Создать новую тему:
Автор:
Закрыть
Цитировать
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / NPGSQL System.Exception: Timeout while getting a connection from pool.
1 сообщений из 1, страница 1 из 1
NPGSQL System.Exception: Timeout while getting a connection from pool.
    #38734791
Фотография des1roer
Скрыть профиль Поместить в игнор-лист Сообщения автора в теме
Участник
Пишу простой опросник тсп портов.
Но вот стала валиться ошибка System.Exception: Timeout while getting a connection from pool.
либо же
A timeout has occured. If you were establishing a connection, increase Timeout value in ConnectionString. If you were executing a command, increase the CommandTimeout value in ConnectionString or in your NpgsqlCommand object.
Причем то все ок, то ошибка валится. Кто сталкивался?
Код: c#
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44.
45.
46.
47.
48.
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
63.
64.
65.
66.
67.
68.
69.
70.
71.
72.
73.
74.
            {
                try
                {
                    while (doWork)
                    {
                        // Create a TcpClient.
                        // Note, for this client to work you need to have a TcpServer 
                        // connected to the same address as specified by the server, port
                        // combination.
                        TcpClient client = new TcpClient(Server, Port);

                        // Translate the passed message into ASCII and store it as a Byte array.
                        Byte[] data = Encoding.UTF8.GetBytes(msg);
                        // Get a client stream for reading and writing.


                        NetworkStream stream = client.GetStream();

                        // Send the message to the connected TcpServer. 
                        stream.Write(data, 0, data.Length);

                        // Receive the TcpServer.response.
                        // Buffer to store the response bytes.
                        data = new Byte[256];


                        // String to store the response ASCII representation.

                        // Read the first batch of the TcpServer response bytes.
                        Int32 bytes = stream.Read(data, 0, data.Length);


                        value = System.Text.Encoding.ASCII.GetString(data, 0, bytes);
                        value = value.Substring(0, value.Length - 1);
                   
                           stream.Close();
                           client.Close();
                        if (value[0] == '$' && value.Length <= 13)
                        {
                            NpgsqlConnection conn_ = new NpgsqlConnection(("Server=" + list[0] + ";Port=" + list[1] + ";User Id=" + list[2] + ";Password=" + list[3] + ";Database=" + list[4] + ";Timeout=300; CONNECTIONLIFETIME=300; CommandTimeout = 300 "));
                            if (conn_.State == System.Data.ConnectionState.Closed) conn_.Open();
                            if (ParseGlob != "") Mystr = ("INSERT INTO " + list[5] + "(\"F_TagName_ID\"," + list[9] + ",\"F_Date\")  VALUES (" + IdCom.ToString() + ",(SELECT * FROM " + ParseGlob + "(\'" + value + "\')),\'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\'   )");
                            else Mystr = ("INSERT INTO " + list[5] + "(\"F_TagName_ID\"," + list[9] + ",\"F_Date\")  VALUES (" + IdCom.ToString() + ",\'" + value + "\',\'" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "\'   )");
                            logger.Trace(Mystr);

                            NpgsqlCommand command = new NpgsqlCommand(Mystr, conn_);
                            command.CommandTimeout = 20;
                            int rowsaffected;
                            try
                            {
                                rowsaffected = command.ExecuteNonQuery();
                            }
                            catch (Exception msg2)
                            {
                                logger.Trace(msg2);
                            }
                            if (conn_.State == System.Data.ConnectionState.Open)
                                conn_.Close();
                            wh.WaitOne();
                        }
                        else
                        {
                            logger.Debug("port_DataReceived " + value);
                            value = "";
                            return;
                        }
                    }
                }
                catch (Exception msg)
                {
                    logger.Error(msg);
                    return;
                }
            }
...
Рейтинг: 0 / 0
1 сообщений из 1, страница 1 из 1
Форумы / WinForms, .Net Framework [игнор отключен] [закрыт для гостей] / NPGSQL System.Exception: Timeout while getting a connection from pool.
Найденые пользователи ...
Разблокировать пользователей ...
Читали форум (0):
Пользователи онлайн (0):
x
x
Закрыть


Просмотр
0 / 0
Close
Debug Console [Select Text]