This project has moved and is read-only. For the latest updates, please go here.

Problem with WP8 version

Feb 21, 2013 at 10:48 PM
Edited Feb 21, 2013 at 10:57 PM
Hello,

Tried running the test application with my Lumia 920. The code fails in OnGetResponse:
private void OnGetResponse(IAsyncResult asyncResult)
    {
    byte[] imageBuffer = new byte[1024 * 1024];

    // get the response
    HttpWebRequest req = (HttpWebRequest)asyncResult.AsyncState;
    HttpWebResponse resp = null;
    try
        {
        // This line fails.....
        resp = (HttpWebResponse)req.EndGetResponse(asyncResult);
The error code is: "The remote server returned an error: NotFound."

Thanks,
EitanB
Feb 21, 2013 at 10:52 PM
Exception? HTTP error code? Site you're connecting to? Does it work with any of the other platforms (WinForms/WPF/etc.)? Any other details? Not really enough to go on here...
Feb 21, 2013 at 10:56 PM
The error code on the try is:

The remote server returned an error: NotFound.

Thanks,
Eitan
Feb 21, 2013 at 11:02 PM
That's the equivalent of a 404. The URL you're attempting to access is likely incorrect...
Feb 21, 2013 at 11:10 PM
Hi Brian,

It is the correct address for my Widnows 8 version (the camera is on my desk)
        private void Start_Click( object sender, RoutedEventArgs e )
            {
            _mjpeg.ParseStream( new Uri( "http://192.168.1.6/videostream.cgi" ), "admin", "" );
            }
Feb 21, 2013 at 11:50 PM
Is your phone connected via WiFi on the same network as the camera, or via cell?
Feb 22, 2013 at 1:42 AM
Via WiFi I think.

The phone is connected on my home local WiFi, but also shows full bars (3G).

However, I also tried to run the application in the VS2012 simulator. It gives the same result.

Thanks,
Eitan
Feb 22, 2013 at 2:26 AM
Given the error, it means you're not reaching your camera, or you are, and the page "videostream.cgi" isn't found. If it's working on Windows 8 and not phone, it's likely the former...you're not getting to your camera. I just tried here with the simulator and my physical device and both can hit my local camera just fine. I'm not sure what to suggest other than ensuring that's the proper IP, proper path, doesn't require a :port specifier, the user/password (if required) are correct, and making absolutely sure there's no firewall between the device and the camera, and making sure the device/simulator has a network connection, and is truly are on the same 192.168.1.* network that the camera is on...

Here's the URI of a public cam I just found...see if you can connect to this:

http://88.53.197.250/axis-cgi/mjpg/video.cgi?resolution=320x240
Feb 22, 2013 at 3:26 AM
Edited Feb 22, 2013 at 3:44 AM
I think I found a solution, not sure I understand the problem though.

CASE A: Works
I include the user and pwd data in the URI to the ParseStream
        private void Start_Click( object sender, RoutedEventArgs e )
            {
            _mjpeg.ParseStream( new Uri( "http://192.168.1.6/Videostream.cgi?user=admin&pwd=" ) );
           }
CASE B: Does not Work
I don't include the user & pwd data in the URI to the ParseStream and they are passed to the Credentials (this is how it works in my Win8 solution)
        private void Start_Click( object sender, RoutedEventArgs e )
            {
            _mjpeg.ParseStream( new Uri( "http://192.168.1.6/Videostream.cgi" ), "admin", "" );
           }
The ParseStream is defined below:
        public void ParseStream( Uri uri )
            {
            ParseStream( uri, null, null );
            }

        public void ParseStream( Uri uri, string username, string password )
            {
            HttpWebRequest.RegisterPrefix( "http://", WebRequestCreator.ClientHttp );
            HttpWebRequest httpWebRequest = (HttpWebRequest)HttpWebRequest.Create( uri );
            if ( !string.IsNullOrEmpty( username ) || !string.IsNullOrEmpty( password ) )
                {
                httpWebRequest.Credentials = new NetworkCredential( username, password );
                }

            // start the stream immediately
            httpWebRequest.AllowReadStreamBuffering = false;

            // asynchronously get a response
            httpWebRequest.BeginGetResponse( OnGetResponse, httpWebRequest );
            }
Do you have any clue why one way works and one way does not (but works on Win8)?

Thanks,
Eitan
Feb 22, 2013 at 3:54 AM
Hm...not sure. What happens if you remove the user/pass from the URI and only pass via the network credentials? I use it in this way and it works with my Cisco camera...
Feb 22, 2013 at 4:03 AM
This is what I did in CASE B that doesn't work on the phone but works fine on Win8 :( Somehow the credentials are ignored by the camera or not sent by the phone?!

I have no explanation to this do you?

I also tested CASE A for Win8 and it works. I think I will change it there too, just to be on the safe side and to have the same code.

Thanks
Eitan
Feb 22, 2013 at 3:59 PM
I missed your edit....

I am using CASE B above with my Cisco camera with both Win8 and WP8 (URI with no user/pass, but sending user/pass via NetworkCredentials) and it works just fine with my Cisco camera. I'm not sure why it's not working against your Foscam (yes?) camera. Very strange...I don't have an explanation...
Feb 24, 2013 at 12:53 AM
Hi,

I am finding another problem with the phone. I implemented movement control (up, down, left, right) buttons.

As the application starts I turn the video on (in OnNavigatedTo). If I press one of the movement buttons, and the phone was just turn on, it causes the application to crash.

This happens when running in the VS2012 simulator or the device itself. If I'll restart the application after a crash, the movement buttons operate fine without crashing the application.

Do you have any experience similar to that or idea why it happens?

Thx
EitanB


Sent from my Windows Phone

From: peekb
Sent: ‎2/‎22/‎2013 7:59 AM
To: eitanbarazani@hotmail.com
Subject: Re: Problem with WP8 version [mjpeg:434039]

From: peekb

I missed your edit....

I am using CASE B above with my Cisco camera with both Win8 and WP8 (URI with no user/pass, but sending user/pass via NetworkCredentials) and it works just fine with my Cisco camera. I'm not sure why it's not working against your Foscam (yes?) camera. Very strange...I don't have an explanation...
Feb 24, 2013 at 3:46 AM
That's a bit outside the realm of MJPEG, but send me a project that reproduces the error and I can take a look...
Aug 22, 2013 at 4:51 PM
Edited Aug 22, 2013 at 4:52 PM
This problem only seems to happen with public addresses or network. Connecting via wifi to my local camera works fine but going through public ip with port forwarding doesn't although calling the address inside browser works, so the setup is correct. Also works on android app.
But for truth's sake other apps seem to have deceased to work with mpjeg on public ip...