Is there any way to disable web socket connections or end a web socket connection through Chrome's developer tools network tab?
I've noticed that turning throttling under the network tab to Offline doesn't affect web socket connections that have already been established. It only prevents traditional HTTP requests from going out.
There's a question here related to this, but it's woefully outdated.
February 2022 update
As of Chrome 99 this is supported: https://developer.chrome.com/blog/new-in-devtools-99/#websocket
Original answer
No, there is no way to disable or close a connection from the Network panel. Source: DevTools Engineer.
If you have a reference to the WS connection, though, you can close it via the Console using its JS API.
You can close idle and flush your inactive socket pools in the Net Internals page in Chrome. However, this unfortunately only closes your active sockets by the looks of it.
chrome://net-internals/#sockets
You would have to use the WebSockets API and call close() on a reference to an existing socket to close it explicitly. Otherwise, killing the process with the active socket is all I can think of.
I assume you want to test unexpected connection failures, it is possible, but not through Network-tab and you need to be able to log from code.
You can close Websocket connections if you are able to use console.dir(socket) even when you could not store the connection reference, e.g. due sandboxing. Via console.dir() you are able to gain a reference to the socket by right clicking the console.dir() output of the websocket and choosing "Store object as global variable". Then call close() on the temporary reference and the connection you want to terminate closes.
Related
While working on a project, I've observed that, if a open a single Chrome tab, there are multiple socket connections being made. Ideally I assumed, there should be only one connection, that is from my local machine to the google server.
Here is the netstat results of multiple remote connections made:
Why are there many connections made instead of one? Please clear this doubt for me, thanks.
Because when you open a Chrome tab, it will load not only one resources from the internet(maybe not just from Google). You can use some HTTP/S request capture tools like fiddler or HTTP Analyzer to see those requests.
We load data from a few subdomains/3rd parties. This causes about 100ms of SSL handshaking for each domain. I'm wondering if there is a way to "pre-fetch-handshake" similar to how dns-prefetching works. Does dns-prefetching already do this?
I doubt that there is a pre-fetch-handshake and I doubt that it would make sense. DNS prefetching is done for links in the page so that the browser already knows the IP address of the target host when the user decides to click the link. This might be immediately after loading the page, some minutes later, hours later or never. DNS prefetching also does not tie any resources on the server. It just warms up the local DNS cache by asking the upstream DNS resolver which might either have the record already or will resolve the query and thus have the entry in the cache, available for other clients too.
Contrary to this a pre-fetch-handshake for HTTPS would need to create a TCP connection directly to the target server, do the SSL handshake and then wait for the client to click. This ties up resources at the client and the server so after some time of inactivity the server will close the connection to free these resources. Thus in many cases this would just waste resources on both sides since the link will never be clicked or will only be clicked after the server already closed the idle connection.
The situation is a bit different if the link points to a site with an already existing connection, like a same-site link when loading a page from some site. Today browsers use persistent HTTP connections and will try to leave the connection to a site open for a while in case more requests need to be send. If the user then clicks the same-site link an existing connection might be used which was still open from previous requests. Of course these connections tie up resources on the server too so the server will close the connection after some idle time too.
How to revive HttpClient and make it see that the network is available again without fully restarting the application?
In case when a Xamarin.Forms app was launched with no network connection available and then later network connection is enabled, HttpClient.SendAsync(request) throws NameResolutionFailure and it does not recover, no matter how many times the request is repeated.
It seems, HttpClient does not know how to recover when network connection appears.
To reproduce the issue in Android emulator:
ensure your app is completely closed
turn network off (set Data status to Roaming in emulator settings or use the status bar to toggle the data or LTE switch).
launch your app, run a web request to verify that it does not work (obviously, you will need try/catch around the web request to avoid crashing)
while the app is still open, enable the network
run a web request - will get NameResolutionFailure
only full application restart will revive HttpClient
The issue does not happen if I use domain names specified in etc/hosts file.
I tried to fully recreate HttpClient and resend a new request when the issue occurs, but that does not help. Only full restart of the app helps.
Obviously, I cannot ask user to fully kill my app and start it again every time when user has turned on his network connection after launching my app.
This is a known issue. See:
Mono: https://bugzilla.xamarin.com/show_bug.cgi?id=45761
iOS: https://bugzilla.xamarin.com/show_bug.cgi?id=45763
Android: https://bugzilla.xamarin.com/show_bug.cgi?id=45383
The workaround is to manually set the DNS refresh:
System.Net.ServicePointManager.DnsRefreshTimeout = 0;
Sometimes an exception causes application pool to shutdown. I start it manually but the question is how can I automate this behavior in IIS 7.0 (Windows server 2008).
If an application pool dies, the next request for a resource served by that pool will automatically restart it. If, however, you have rapid fail protection enabled on the app pool, and the pool dies more times than the number specified by the maximum failures property within the interval specified by the failure interval property, then you will receive a 503 Service Unavailable message. At this point, you will have to manually restart the app pool.
To work around this, either disable rapid fail protection for the app pool, or try increasing the number of faults within the time period, and then determine the root cause of the exceptions which are terminating the app pool.
open iis select your website and on right hand side u see Actions
under Browse Web site -> Advanced Setting
select start Automatically to true.
I am having a similar problem in Windows Server 2012 Standard and IIS 8. URLs with an ampersand character at the end cause IIS to freak out, and consider them malicious. This causes the App Pool to fail, crashing the website.
What you need to do is watch the Event Viewer for 1309 events. (In the Event ID column) You can set this up using Task Scheduler. When you see the event, you restart the App Pool.
To restart the App Pool, you can use a .vbs script like this:
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
Set oAppPool = oWebAdmin.Get("ApplicationPool.Name='DefaultAppPool'")
' Recycle the application pool.
oAppPool.Recycle
Or you could use Powershell if you like that better.
I use a pretty neat C# program that I found here:
http://www.west-wind.com/weblog/posts/2012/Oct/02/A-tiny-Utility-to-recycle-an-IIS-Application-Pool
It does a great job, and seems to get around some of the permissions issues that the previous two methods have. I do have to run this script as an admin, though.
Hope this helps. It does not solve the problem, but it will take the heat off until there is a solution to this URL issue.
Sorry for the subject line sounding like an even nerdier Harry Potter title.
I'm trying to use AS3's Socket class to write a simple FTP program to export as an AIR app in Flex Builder 3. I'm using an FTP server on my local network to test the program. I can successfully connect to the server (the easy part) but I can't send any commands. I'm pretty sure that you have to use the ByteArray class to send these commands but there's some crucial piece of information that I'm missing apparently. Does anyone know how to do this? Thanks!
Dave
The FTP protocol predates UTF encoding. Switch to ANSI/ASCII for better results. If you do opt for writeMultiByte instead of writeUTFBytes, be aware that it is buggy in linux. Here's one way around it.
There's another question here where the line ending turns out to be the culprit, so make sure that you get it right (as suggested above).
As said before, if this is running from the web, all socket connections will require a crossdomain policy, but this is NOT file based over HTTP. Recent changes to the security rules mean that any socket based connection must first get a crossdomain from a policy server hosted on port 843 of the target host.
Quoting from Adobe:
A SWF file may no longer make a socket connection to its own domain without a socket policy file. Prior to version 9,0,115,0, a SWF file was permitted to make socket connections to ports 1024 or greater in its own domain without a policy file.
HTTP policy files may no longer be used to authorize socket connections. Prior to version 9,0,115,0, an HTTP policy file, served from the master location of /crossdomain.xml on port 80, could be used to authorize a socket connection to any port 1024 or greater on the same host.
Essentially, what this means is that you must be in control of the target FTP host, and install supplementary software on it to get this working.
Read this link too and maybe it can be useful this one too.
The first one is about policy files and the second is an example of a TELNET (so, no FTP here) client.
I've been able to get an FTP client working in a browser, but it's buggy. I had to get a listener running on port 843 to server the policy file so that Flash would be allowed to connect and transfer data. Then, I had to figure out how FTP actually works:
You have to open 2 sockets: a command socket and a data socket. The command socket is where you send your USER, PASS, CWD, and STOR commands. The data socket is where you write your ByteArray data to. Sending the PASV command will tell you what port your data socket must connect to.
Where it is buggy is on Mac, in both Safari and FF, when I call the "socket.close()" command, the server socket actually closes. On Windoze, it does not. This is a huge problem because the Event.CLOSE event is not fired until the SERVER closes the connection. This is in the livedocs.
This is where I'm at. I have no idea why it would work flawlessly on Mac and then be completely busted in 3 different browsers on Windows. The only thing I can come up with is that it's either something in my Windows configuration that's preventing proper communication with the server, or it's the Window Flash player that's causing the problem.
Any thoughts?
We will need more info to resolve this.. What you're saying here appears correct to me. You're using the Socket class to send data though, not ByteArray.
Are you sure data is not being sent? How are you receiving the response? It may be that it's working fine but you're just not aware of it? As i said, tell us more about what you're doing..
Lee Brimelow has a screencast on gotoAndLearn of writing an POP3 client. It's essentially the same of what you're doing so take a look.
Are you 100% sure the syntax is correct? I know with HTTP you'll have to an include extra linebreak after the request for it to go through. Without it you'll get nothing back. Not sure how it is with FTP though.
The FTP standard requires CRLF at the end of commands. Try using "\r\n" in place of the "\n" in your example.
You must serve the CrossDomain Policy File from your FTP server in order to conect correctly.
From what I've gathered, you have to send each command one at a time and validate the response before moving on. You should be getting something back against ProgressEvent.SOCKET_DATA
Try just this and see what you get in response.
socket.writeUTFBytes("USER "+user+"\n"); socket.flush();
You would then read the response out like this.
var response:String = mySocket.readUTFBytes(mySocket.bytesAvailable);