logo

Live Production Software Forums


Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
davesuemcbride  
#1 Posted : Monday, March 30, 2015 4:44:21 AM(UTC)
davesuemcbride

Rank: Advanced Member

Groups: Registered
Joined: 5/28/2013(UTC)
Posts: 54
Location: USA

Thanks: 4 times
Was thanked: 3 time(s) in 3 post(s)
... seems quite quick - generally 1 or 2 milliseconds between two close physical machines for a status query.

BUT, from time to time I get random periods where it's in the 195 to 210 ms range, i.e. about 100x slower. Oddly, it's either lightning fast, or really slow, but never in-between, so I'd think it's not a loading or traffic issue.

I suspect it's something in my network or OS as opposed to vMix's web server, though I've gone through many obvious steps and see the issue on multiple client machines. These are windows clients, and HttpWebRequest and/or WebClient is used under dotNet 4, both synchronously and asynchronously. After more than a few hours stumped, I'd thought I'd throw out a query for the overnight ;)

Realize I'm giving virtually no useful detail - this is more for anyone who's run into something similar and found something non-obvious. Stuff I've tried already is confirming DNS, checking for IP address conflicts, swapping network hardware, nulling the WebRequest proxy object, KeepAlive, Nagle, dispose / ReadToEnd, ad nauseum. OS is Win7 Pro (64 bit).

Thanks,
David
admin  
#2 Posted : Monday, March 30, 2015 6:59:42 AM(UTC)
admin

Rank: Administration

Groups: Administrators
Joined: 1/13/2010(UTC)
Posts: 5,161
Man
Location: Gold Coast, Australia

Was thanked: 4166 time(s) in 1497 post(s)
Hi David,

What vMix API functions are you using?
Some of them may need to wait for something to complete internally before returning.

Regards,

Martin
vMIx
davesuemcbride  
#3 Posted : Monday, March 30, 2015 12:50:40 PM(UTC)
davesuemcbride

Rank: Advanced Member

Groups: Registered
Joined: 5/28/2013(UTC)
Posts: 54
Location: USA

Thanks: 4 times
Was thanked: 3 time(s) in 3 post(s)
Hi Martin - for the tests below it's only been retrieving status, i.e. '/api/?'.

What sticks out the most is how exact the two timings I'm getting are - it's either 1 or 2 ms, or an almost exact 200 ms. I've confirmed that the actual results are correct at the faster timing, so this is clearly what the web server is capable of. I suspect somewhere on the stack an extra step, like DNS resolution or something, is happening, but why it goes through periods (hours) of needing that step sometimes but not others I have no idea.

David
davesuemcbride  
#4 Posted : Wednesday, April 1, 2015 12:47:29 AM(UTC)
davesuemcbride

Rank: Advanced Member

Groups: Registered
Joined: 5/28/2013(UTC)
Posts: 54
Location: USA

Thanks: 4 times
Was thanked: 3 time(s) in 3 post(s)
Hi Martin - after uninstalling a ton of software, replacing all my network hardware, and pulling a few hundred feet of CAT 2 out of my walls, I accidently stumbled on the trigger. It was about the last thing I expected, and while I can't explain the 'why' part, it's pretty interesting.

Two servers:

(1) 'Mixer' has just vMix all alone, with just ffmpeg encoding, cameras, and a Flash 'SWF' overlay input that does custom graphics (titles, crawl, sponsors, etc), and,

(2) 'Controller', which has a dotNet thick-client UI for selecting races, switching cameras, etc, as well as an IIS web server accessed by the SWF.

'Controller' polls and automates vMix via the API, and 'Mixer' similarly reaches back via the SWF to the IIS website on Controller to keep the graphics up to date. Basically, each machine runs both a web server (vMix & IIS) and a web client (SWF & thick-client UI), so there's a lot of http traffic going both ways.

The trigger seems to be Flash - the presence of the Flash SWF as an input somehow affects the speed of the vMix web server, i.e. a consistent 1 or 2 ms per call vs 200 ms per call, with nothing in-between.

You may now be thinking 'Ah, badly written Flash code hogs and blocks and slows it all down - case closed'. But wait - it's actually the reverse - the vMix web server speeds up when the Flash input is open! I open the Flash input and immediately the vMix API latency drops to insanely fast. Close the Flash input, and that very instant it jumps back up to 200 ms.

There's more... I'd think, 'OK, because of all that back and forth traffic, some network setting between the two machines gets cached or something, so dotNet gets smarter about the http logic, and skips whatever dumb@ss step takes 200 ms'. In that case, Controller would see the benefit, but another separate / third machine would remain slow since it's not part of the Flash conversation. Nope - yet another surprise - when I ran the Controller UI on an otherwise virgin machine it sped and slowed just like Controller. Basically, the benefit Flash gives applies to all clients of the vMix web server.

I'm pretty sure about all the above. In particular I've been sure to test the vMix status output under the insanely fast case to see that old results aren't being cached, but I can clearly see the video position value blurring away faster than I can read. At this point all this is more FYI than support query - even at 200 ms the UI would be usable, though I like it much better at <2 ms ;)

Still unknown - is it just the Flash libraries being loaded that makes the difference, or is it the network traffic my code creates? I may look at that in a couple of weeks when things slow down.

Thanks!
David

davesuemcbride  
#5 Posted : Thursday, April 16, 2015 2:50:05 PM(UTC)
davesuemcbride

Rank: Advanced Member

Groups: Registered
Joined: 5/28/2013(UTC)
Posts: 54
Location: USA

Thanks: 4 times
Was thanked: 3 time(s) in 3 post(s)
I've better refined the circumstances where the API web server has higher latency - it seems to vary by the number of inputs. At <= 2 inputs it's ~200 ms, whereas at >2 inputs it's ~1 ms. In the end there's no significant issue since anyone doing API work would generally have >2 inputs anyway - I'd just stumbled on this doing some simple testing, and it drove my hair out that the latency would vary so much for no apparent reason...
admin  
#6 Posted : Friday, April 17, 2015 10:38:25 PM(UTC)
admin

Rank: Administration

Groups: Administrators
Joined: 1/13/2010(UTC)
Posts: 5,161
Man
Location: Gold Coast, Australia

Was thanked: 4166 time(s) in 1497 post(s)
Ok, now that is starting to make a bit more sense since Windows may sometimes wait for more network data before
sending if there is only a small amount of data to send.

To test this theory, try adding only two inputs but make one of them a title input with a very large amount of text.
This should increase the size of the XML response and should eliminate the delay.

Regards,

Martin
vMix
davesuemcbride  
#7 Posted : Sunday, April 19, 2015 12:20:10 AM(UTC)
davesuemcbride

Rank: Advanced Member

Groups: Registered
Joined: 5/28/2013(UTC)
Posts: 54
Location: USA

Thanks: 4 times
Was thanked: 3 time(s) in 3 post(s)
That's it indeed - you can even see the difference in real-time when pasting long text into the title input dialog!

Something I'd tried on the client side may help on the server side:

// Configure the service point
Uri uri = new Uri(VmixURL + VmixCommand);
ServicePoint servicepoint = ServicePointManager.FindServicePoint(uri);
servicepoint.UseNagleAlgorithm = false;

Negating the UseNagleAlgorithm property is supposed to flush whatever's pending regardless of length. Hoping above code will help retain my 'advanced' status even after floating all sorts of over-complicated theories ;)

Thanks,
David
admin  
#8 Posted : Monday, May 18, 2015 8:44:14 PM(UTC)
admin

Rank: Administration

Groups: Administrators
Joined: 1/13/2010(UTC)
Posts: 5,161
Man
Location: Gold Coast, Australia

Was thanked: 4166 time(s) in 1497 post(s)
Hi David,

The latest update to vMix 15 version 15.0.0.78 has just been released and I have disabled the Nagle algorithm
on the vMix side of things, so responses should be a lot quicker now.

Try it out and let me know if it helps.

Regards,

Martin
vMix
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.