I am writing a UWP app using the Windows.Devices.WiFi to basically get a lists of networks. Everything was working fine when I retrieved the information a time or two. However, I wanted to put the code into a timer so I can report regularly. Once I did this, I got "an attempt was made to establish a session to a network server, but there are already too many sessions established to that server."
I am not sure what is establishing connections as I am just trying to read the information. I am not even calling the ConnectAsync calls.
Can anyone help me out? I need to know what to dispose, or close, etc.
Update: Further analysis, I am finding that the call to FindAllAdaptersAsync multiple times is causing this issue.
I decided to cache up the list of adapters by only calling FindAllAdaptersAsync once. Thanks for the idea Henk. This seemed to fix my issue for now. However, I think that it is a bug with FindAllAdaptersAsync. I would think you should be able to call this as much as you like, unless maintaining the network connection is necessary every time. Or at least a way to free them up.
Related
I have problem in refreshing data in a Windows Forms application. I have one server (it is also an other client) and one client. My task is to update data in list by clicking on button and server side client is updating properly, but in client it is not updating for the first time.
But by keeping debug point on particular point it is updating on client side also. I understood that this is happening because of Timing issue, so I used Thread.Sleep();.
But still I am facing the same problem.
I am not able to understand why this is happening without changing any code.
Do not ever -EVER- use Thread.Sleep(); This is just something you do when you're trying out stuff but has pretty much no use in production.
That being said, you're experiencing a race condition, which are usually annoying to debug because they depend on server-client communications.
I suggest you take a look at async-await, if you haven't already, and you set your code so you wait (await) for the server to give you the update before updating your UI.
If you're already using async/await I suggest you show us some code so we can at least help you out a little. But with the information currently available, I suggest you look this up and learn a bit from there. It'll help a lot
I'm facing a very difficult problem with a web a application that I'am implementing with a group of developers. We are using Simple Data to connect to a Oracle database but after several connection or when we have a lot of users the connection pool gets full and the application doesn't work any more. The problem is that Simple Data opens the connection to make the transactions but it never close the connection so the application stops the transactions, we saw at the simple data documentation that it says that althought in code it's not necessary to close the connection the simple data do it itself but is not true.
We already try to change the number of available connection from 100 to 50 per user, but the problem continues, another solution that we implemented was to open a share connection, but it didn't work either. The question is, Is there a way in code to Close the connections in the simple data?.
var db=Database.Open();
return db.Table.FindById(Id:2);
In that sample code, you can see that I open the connection, but there is no method to close it. If someone can help me with this problem I'll be grateful. Thank you.
Info:
We are using, NancyFx framework, C# an Oracle11g database.
Old post but if anyone wondering about it! ...
As the docs on page (http://simplefx.org/simpledata/docs/pages/Start/OpeningAConnection.html) saya at the last line
Simple.Data is quite aggressive in closing connections and holds no open connections to a data store by default, so you can keep the Database object returned from the Open*() methods hanging around without worrying.
I was looking for some advice on the best approach to a TCP/IP based server. I have done quite a bit of looking on here and other sites and cant help think what I have saw is overkill for the purpose I need it for.
I have previously written one on a thread per connection basis which I now know wont scale well, but what I was thinking was rather that creating a new thread per connection I could use a ThreadPool and queue the incoming connections for processing as time isn't a massive issue (provided they will be processed in less that a minute or two of coming in).
The server itself will be used essentially for obtaining data from devices and will only occasionally have to send a response to the sending device to update settings (Again not really time critical as the devices are setup to stay connected for as long as they can and if for some reason if it becomes disconnected the response will be able to wait until the next time it sends a message).
What I wanted to know is will this scale better than the thread per connection scenario (I assume that it will due to the thread reuse) and roughly what kind of number of devices could this kind of setup support.
Also if this isn't deemed suitable could someone possibly provide a link or explanation of the SocketAsyncEventArgs method. I have done quite a bit of reading on the topic and seen examples but cant quite get my head around the order of events etc and why certain methods are called at the time the are.
Thanks for any and all help.
I have read the comments but could anybody elaborate on these?
Though to be honest i would prefer the initial approach of of rolling my own.
I'm working on an IRC implementation in C#. My work is based off of IRC.NET, and I have this problem that keeps cropping up. According to wireshark, my session is almost identical to X-Chat, where the problem does not occur. The problem in question is that after about 10 minutes of perfect operation, it stops working out of nowhere. No exceptions occur, but the bot is unable to send messages and sees nothing from the server. I respond to pings and such appropriately. After a while, the server (FreeNode) reports that the bot has pinged out, but the client knows nothing of it.
It is a very frustrating bug, and I have no idea what is causing it.
EDIT:
Here are some relevant links:
Library my work is based on (I have made very few changes)
The bulk of the relevant code is in IrcClient.cs
Here's most of my code for working against the library: Link
Have you considered that it might be due to garbage collection? It would be good to see if you can establish whether or not your server or timer objects are being collected
I currently have a working program that is monitoring a few SQL tables and transferring data to MySQL tables. Essentially, I have a loop that checks every 30 seconds. My main concern is that I currently need to close and open the connection every time I loop. The reason for this is because I was getting errors about multiple transactions. When I close my connections, I also need to dispose the connection. I thought that disposing the transactions would have solved this problem, but I was still getting errors about multiple transactions.
This all seems to be working fine but I was wondering if there was a better way to do this without closing the connection.
I am not sure about your errors but it seems that you have to increase the number of connections to the remote computer. Have a look here http://msdn.microsoft.com/en-us/library/system.net.configuration.connectionmanagementelement.maxconnection.aspx
Also you can try to do is use only one connection to realize multiple SQLs.
If it is doesn't help then please provide your code to check it...
Were you committing your transactions in your loop? transaction.Commit() ... that could have been the issue... Hard to say with no code. No need to worry about opening and closing connections anyways since ADO.NET uses connection pooling behind the scenes. You only actually 'open' a connection the first time, after that is kept open in the pool to be used again. As others have said though, Post some code!