How to check how much data flutter sends in API call? - flutter

I am using Visual Studio Code and DevTools but I cannot see how much data flutter sends in API call ?
In Devtools there is a Network tab but it only shows Header content length which is not representation of bytes.
I would like to see it in Bytes (mega, kilo, etc.). because it would be useful when sending Images / Videos to the backend.
Is there any way apart from starting wireshark or usage on my router ?

Related

Why my website keeps requesting resources from server even after the website is fully loaded

I am working on the web vitals for a website and I was checking the Chrome Developer Tools the Network tab. The website loads fully, but I see that in the network tab, the server requests keep on increasing and the resources requested go up to 7.8MB and the website has a slider that keeps repeating in the network. How can I check why so many requests are made?
Here is the picture of the network tab of the website.
I see that the resource names are slide-X.jpg. Without seeing the website or its code, I can only guess that there's a carousel on the page that cycles through images. If the images aren't cacheable, they'd continue to be loaded over the network. Otherwise if they are cacheable, I'd expect to see no network requests at all or at worst a 304 HTTP "Not Modified" response code.
So I'd recommend confirming what kinds of widgets are on the page like a carousel with repetitive behavior and checking the cache control headers of static content like images to avoid the need to load the images each time. Personally, I think carousels are bad UX so I'd even suggest you consider removing it all together! Regardless, you should still cache your content more efficiently.

Chrome hangs after certain amount of data transfered - waiting for available socket

I've got a browser game and I have recently started adding audio to the game.
Chrome does not load the whole page and gets stuck at "91 requests | 8.1 MB transferred" and does not load any more content; and it even breaks the website in all other tabs, saying Waiting for available socket.
After 5 mins (exactly) the data are loaded.
This does not happen on any other browser.
Removing one MP3 file (the latest added one) fixed the problem, so is it perhaps a data limit problem?
Explanation:
This problem occurs because Chrome allows up to 6 open connections by default. So if you're streaming multiple media files simultaneously from 6 <video> or <audio> tags, the 7th connection (for example, an image) will just hang, until one of the sockets opens up. Usually, an open connection will close after 5 minutes of inactivity, and that's why you're seeing your .pngs finally loading at that point.
Solution 1:
You can avoid this by minimizing the number of media tags that keep an open connection. And if you need to have more than 6, make sure that you load them last, or that they don't have attributes like preload="auto".
Solution 2:
If you're trying to use multiple sound effects for a web game, you could use the Web Audio API. Or to simplify things, just use a library like SoundJS, which is a great tool for playing a large amount of sound effects / music tracks simultaneously.
Solution 3: Force-open Sockets (Not recommended)
If you must, you can force-open the sockets in your browser (In Chrome only):
Go to the address bar and type chrome://net-internals.
Select Sockets from the menu.
Click on the Flush socket pools button.
This solution is not recommended because you shouldn't expect your visitors to follow these instructions to be able to view your site.
Looks like you are hitting the limit on connections per server. I see you are loading a lot of static files and my advice is to separate them on subdomains and serve them directly with Nginx for example.
Create a subdomain called img.yoursite.com and load all your images
from there.
Create a subdomain called scripts.yourdomain.com and load all your JS and CSS files from there.
Create a subdomain called sounds.yoursite.com and load all your MP3s from there... etc..
Nginx has great options for directly serving static files and managing the static files caching.
The message:
Waiting for available socket...
is shown, because you've reached a limit on the ssl_socket_pool either per Host, Proxy or Group.
Here are the maximum number of HTTP connections which you can make with a Chrome browser:
The maximum number of connections per proxy is 32 connections. This can be changed in Policy List.
Maximum per Host: 6 connections.
This is likely hardcoded in the source code of the web browser, so you can't change it.
Total 256 HTTP connections pooled per browser.
Source: Enterprise networking for Chrome devices
The above limits can be checked or flushed at chrome://net-internals/#sockets (or in real-time at chrome://net-internals/#events&q=type:SOCKET%20is:active).
Your issue with audio can be related to Chrome bug 162627 where HTML5 audio fails to load and it hits max simultaneous connections per server:proxy. This is still active issue at the time of writing (2016).
Much older issue related to HTML5 video request stay pending, then it's probably related to Issue #234779 which has been fixed 2014. And related to SPDY which can be found in Issue 324653: SPDY issue: waiting for available sockets, but this was already fixed in 2014, so probably it's not related.
Other related issue now marked as duplicate can be found in Issue 401845: Failure to preload audio metadata. Loaded only 6 of 10+ which was related to the problem with the media player code leaving a bunch of paused requests hanging around.
This also may be related to some Chrome adware or antivirus extensions using your sockets in the backgrounds (like Sophos or Kaspersky), so check for Network activity in DevTools.
simple and correct solution is put off preload your audio and video file from setting and recheck your page your problem of waiting for available socket will resolved ...
if you use jplayer then replace preload:"metadata" to preload:"none" from jplayer JS file ...
preload:"metadata" is the default value which play your audio/video file on page load thats why google chrome showing "waiting for available socket" error
Our first thought is that the site is down or the like, but the truth is that this is not the problem or disability. Nor is it a problem because a simple connection when tested under Firefox, Opera or services Explorer open as normal.
The error in Chrome displays a sign that says "This site is not available" and clarification with the legend "Error 15 (net :: ERR_SOCKET_NOT_CONNECTED): Unknown error". The error is quite usual in Google Chrome, more precisely in its updates, and its workaround is to restart the computer.
As partial solutions are not much we offer a tutorial for you solve the fault in less than a minute.
To avoid this problem and ensure that services are normally open in Google Chrome should insert the following into the address bar: chrome: // net-internals (then give "Enter"). They then have to go to the "Socket" in the left menu and choose "Flush Socket Pools" (look at the following screenshots to guide http://www.fixotip.com/how-to-fix-error-waiting-for-available-sockets-in-google-chrome/)
This has the problem solved and no longer will experience problems accessing Gmail, Google or any of the services of the Mountain View giant. I hope you found it useful and share the tutorial with whom they need or social networks: Facebook, Twitter or Google+.
Chrome is a Chromium-based browser and Chromium-based browsers only allow maximum 6 open socket connections at a time, when the 7th connection starts up it will just sit idle and wait for one of the 6 which are running to stop and then it will start running.
Hence the error code ‘waiting for available sockets’, the 7th one will wait for one of those 6 sockets to become available and then it will start running.
You can either
Clear browser cache & cookies (https://geekdroids.com/waiting-for-available-socket/#1_Clear_browser_cache_cookies)
Flush socket pools (https://geekdroids.com/waiting-for-available-socket/#2_Flush_socket_pools)
Flush DNS (https://geekdroids.com/waiting-for-available-socket/#3_Flush_DNS)

Flex mobile project for IOS, server side proxy

I am trying to write an iphone app that loads a video from an inbuilt web server running off a camera (connect to iphone via wifi).
I am using flash builder / flex mobile project - not particularly familiar but finding it easier to understand than xcode !!
The files from the camera have the wrong file extension so will not play on the ios video app, can I set up a server side proxy in flex mobile and use this to alter the file extension and then pass this link to the ios video app ?
If so any help anybody could give me ( examples etc) would be really grateful received , I have been trying to get round this problem for a couple of weeks .
Cheers
Toby
I can explain, conceptually, what a server side proxy would do in this case. Let's say you are retrieving a URL, like this:
http://myserver.com/somethingSomething/DarkSide/
to retrieve a video stream from the server. You say it won't be played because there is no file extension; so you have to, in essence, use a different URL with the extension. Set up 'search engine friendly' URLs on the server. And do something like this:
http://myserver.com/myProxy.cfm/streamURL/somethingSomething%5CDarkSide/Name/myProxyVid.mp4
Here is some information on how to deal with Search Engine Friendly URLs in ColdFusion. Here is some information on how to deal with Search Engine Friendly URls in PHP. I'm sure Other technologies will come up in a Google Search.
In the URL above; this is what you have:
http://myserver.com/: This is your server
myProxy.cfm: This is your server side file; that is a proxy
streamURL/somethingSomething%5CDarkSide/Name/myProxyVid.mp4: This is the query string. It consists of two name value pairs. The first is the streamURL. This is the URL you want to retrieve with your proxy. The second is just random; but as long as it ends with the file extension .mp4 the URL should be seen as an 'mp4 file'
The code behind your myProxy.cfm should be something like this, in psuedo-code:
Parse URL Query String
Retrieve Stream.
Set mimeType on return value.
Return stream data
I used a similar approach on TheFlexShow.com to track the number of people who watch our screencast on-line vs downloading it first. I also used the same approach to keep track of impressions of advertiser's banner ads. For example, the browser can't tell that this is not a JPG image:
http://www.theflexshow.com/blog/mediaDisplay.cfm?mediaid=51
Based on this, and one of your previous questions; I am not convinced this is the best solution, though. I make a lot of assumptions here. I assume that the problem with playing the file does relate to the extension and not the file data. I assume that you are not actually streaming video with an open connection on both client and server to send data back and forth.

How do I extract streamed "now playing" data embedded in an Icecast audio (radio) stream on Samsung Smart-TV

I am creating a Samsung TV app for a radio station and they provide the "Now Playing" info within the Icecast stream. Is it possible to (and how do I) extract this information?
Shoutcast supports "Icy-MetaData" - an additional field in the request header. When set, its a request to the shoutcast server to embed metadata about the stream at periodic intervals(once every "icy-metaint" bytes) in the encoded audio stream itself. The value of "icy-metaint" is decided by the shoutcast server configuration and is sent to the client as part of the initial reply.
Check out this post on Shoutcast Internet Radio Protocol for details on icy:metadata and sample code in C.
A somewhat more technical discussion is also available at
http://forums.radiotoolbox.com/viewtopic.php?t=74
Yes, this is possible. The metadata is interleaved into the stream data at a specified interval. Basically, you read 8192 bytes (or whatever is specified by the Icy-MetaInt response header), and then you read the metadata block.
The first byte of that metadata block tells you the length of the data. A length of 0 means there is no updated metadata.
Once you read the meta block, then you go back to reading stream data.
I have all of this in more detail on my answer here: https://stackoverflow.com/a/4914538/362536 While I know you're not writing PHP, the principal is identical no matter what language.
From native player there is no option to get this meta.
You could probably use jQuery.stream plugin to fetch the meta directly - but you need to setup Access-Control-Allow-Origin on you icecast server - but I have no idea if it will work.
The best solution here will be to use this script:
http://code.google.com/p/icecast-now-playing-script/
So you install this script on your web server and from the SmartTV application you will AJAX it once for a while, while your stream is playing.
I just created a radio player for icecast and centova, it uses lastFM api to extract the song meta data. https://github.com/johndavedecano/Icecast-Centova-LastFM-API
If you are doing this for a radio station, then they can provide this data through the XSLT feature of Icecast. Some random old XSLT examples for offering stream metadata that I did at some point.
The other option is to run Icecast 2.4.1 or add the two files (xml2json.xsl status-json.xsl) to an old version.
Note that only Icecast 2.4.1 or newer supports adding CORS/ACAO headers that might be necessary to access data from a web app / web site.
If you are not directly cooperating with the radio station and can't ask them to do this, then disregard this answer. Someone else might find it useful though.

Sending data to a server for computation

I want to create an application which will will be a webapp. I want to collect the data from the user, send it to a server where the computation will take place, and have the result displayed on the iPhone screen. The server normally takes results from a regular webpage via text fields and computes it and displays the result on the webpage. I just want the send the data via iPhone. Navigating my iPhone safari to the webpage is NOT an option, as the webpage is not optimized. So I how do I send data to the server, make it compute the results and have the results displayed on my iPhone?
Thank you.
Regards
EDIT:
I have no control over the server. Imagine my case to be as follows: The user enters a word, the word is sent by the iPhone to a Google server, the server compiles the search results and sends it back to my iPhone, and then the iPhone displays this result on the screen.Any more suggestions?
You might consider using ASIHTTPRequest/ASIFormDataRequest if you want to submit form data to your existing web page using form fields (per your description.)
In general I find ASIHTTPRequest friendlier to use than NSURLConnection / NSURLRequest.
http://allseeing-i.com/ASIHTTPRequest/
The most straightforward way is to use NSMutableURLRequest to create the GET or POST request, and then NSURLConnection to (asynchronously) send the data and receive the result. You could also use any number of third-party libraries to do the same thing.
As for the server side of things, you would have it accept a GET or POST just as you would with a web-based app, and output data in an appropriate format.
As for the output format that will be parsed by your app: With the standard classes, you can easily parse plist data and (with a little more work) XML; third-party libraries can be found to parse json and many other formats, if you so desire.