Cloud and Software Architecture, Soft skills, IOT and embedded
Browsers open extra connections in anticipation of additional requests
Get link
Facebook
Twitter
Pinterest
Email
Other Apps
Browsers can open extra connections or pre-stage open connections to improve the user experience. You can see this if you build your own web server for IoT devices or monitor the connections and not just the requests. These pre-staged connections do not show up in the browser developer tools.
I was troubleshooting a connection timeout issue in a Python-based web server where there were sometimes suspicious connections that timed out. All my testing was done via a browser rather than Postman so I decided to investigate if it was a browser issue or a problem with my service. The developer tools console in Chrome did not show the extra connection in the network traces.
The Python web server generating the logs has a 10-second connection timeout. A single browser action appears to generate two inbound connection requests but only one HTTP request. The 2nd inbound connection appears to be timing out if the user doesn't click on or initiate any additional browser action.
Got a connection from ('127.0.0.1', 64753)
Request Bytes:706
Request Processing: GET/?out_0=off HTTP/1.1
Parameters: {'out_0': 'off'}
Connection closed
Got a connection from ('127.0.0.1', 64754)
Connection closed on error timed out None
Using Wireshark
Neither the Chrome Browser nor the Edge Browser showed any 2nd connection. I installed Wireshark and set it up to capture inbound traffic on localhost. Then I hit return in the URL bar and saw that two connections were opened to the python server within 5 seconds. This called for more investigation
The HTML contains a markup that causes the browser to not fetch favicon.ico and the trace shows that no favicon.ico request was made.
Chrome: Refresh the URL
This trace shows two sockets opened up when I hit the reload request. The first request is the reloaded HTTP GET on "/". The second request comes about 0.5 seconds after the first. No HTTP request is made on the second socket. The Python code times out the open connection after 10 seconds. You see this around the 10.57 timestamp. Sometime later the Browser attempts to keep the socket open.
Chrome: 2 Button Clicks that both do a GET
This trace shows two sockets opened up when I hit the reload request. The first request is clicking on a link on the page. The second socket opening comes about 0.55 seconds after the first. I then click on a 2nd link about 5 seconds after that and the request is processed on the previously opened socket.
Edge: Retains two open connections
I hit the reload button in edge and ended up with two timeout messages in the logs. Wireshark shows that Edge immediately opens two connections. One services the inbound GET request and the other waits. The inbound requests are processed in about 0.5 seconds like the Chrome numbers above. Edge then opens the 3rd connection so that it has two available. The 2nd connection times out at about the 10-second mark in line with our connection timeout. The 3rd connection times out 10 seconds after that.
Edge: An example of connection staging
This example shows how Edge appears to manage connections across two GET requests. In this case, these were hitting the return key in the URL bar. The browser immediately opens two connections. The first connection handles the GET request. A third connection is opened when the first connection completes. The button on the page generates the GET request around the 4.8 second mark. The python server times out the 3rd connection 10 seconds later at the 14.8 second mark. Then there is some other activity at the 30-second mark, probably the browser timeout.
The Windows Subsystem for Linux operates as a virtual machine that can dynamically grow the amount of RAM to a maximum set at startup time. Microsoft sets a default maximum RAM available to 50% of the physical memory and a swap-space that is 1/4 of the maximum WSL RAM. You can scale those numbers up or down to allocate more or less RAM to the Linux instance. The first drawing shows the default WSL memory and swap space sizing. The images below show a developer machine that is running a dev environment in WSL2 and Docker Desktop. Docker Desktop has two of its own WSL modules that need to be accounted for. You can see that the memory would actually be oversubscribed, 3 x 50% if every VM used its maximum memory. The actual amount of memory used is significantly smaller allowing every piece to fit. Click to Enlarge The second drawing shows the memory allocation on my 64GB laptop. WSL Linux defaults to a maximum RAM size of 5
I wanted to access all my Azure resources without making any of them visible to the Internet. The easiest give my local machine access to everything on my Azure Virtual Network (VNET) was to connect to it over VPN. It turns out creating Azure VPN gateways and connecting to Azure VPN endpoints is easy. There are some subtleties in getting DNS name resolution to work that can confuse when first starting out. Setting the Stage There are a few ways to get to Azure endpoints and resources that are blocked from the internet. We can Create a Point-to-Site connection from our local machines to Azure Network Gateways Create a Site-to-Site network connection from our local networks to Azure Network Gateways. Use Bastion Hosts Use Cloud Shell Leave everything open to the internet. I chose a Point-to-Site (P2S) VPN connection that connects from my laptop to a VNet Gateway. That joins my laptop
Create Storage Spaces in Windows 10 Windows Server O/S contains Storage Spaces support for Server Spaces tiered storage. You can front slower spinning disks with smaller faster SSDs. Windows 10 has a Storage Spaces GUI Control Panel that does not include the tiered storage GUI. This means Powershell must be used for all configuration. https://github.com/freemansoft/win10-storage-spaces contains scripts that create tiered storage pools that integrate SSDs as caching drives and HDDs as storage drives. They assume you have at least one SSD and one HDD. The scripts automatically find all raw drives and add them to the pool. Some HDDs have their types incorrectly identified. The script can coerce them to be MediaType:HDD The entire virtual drive is added to the system as a single large volume You need at least 1 SSD and 1 HDD to run cached storage / Simple resiliency 2 SSD and 2 HDD to run cached storage / Mirror resiliency / 1 SSD and 2 HDD to run cached storage / Simple re
Comments
Post a Comment