Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GetProfiles command not working while installing device onvif camera on aws ec2 instance #156

Open
Shadab995 opened this issue Sep 7, 2022 · 22 comments
Labels
1-low priority denoting isolated changes question Further information is requested tapo Tapo Camera

Comments

@Shadab995
Copy link

Shadab995 commented Sep 7, 2022

🐞 Bug Report

Description and Minimal Reproduction [REQUIRED]

I'm running this command curl -s http://host-ip:59882/api/v2/device/name/Camera001/Profiles | jq -r '"profileToken: " + '.event.readings[].objectValue.Profiles[].Token'' and it's giving me the output as null but I have 2 profiles on my UI Dashboard.

can you please help me to solve this issue.

thank you

🔥 Exception or Error





🌍 Your Environment

Deployment Environment:

EdgeX Version [REQUIRED]:

Anything else relevant?

@Shadab995 Shadab995 added the bug Something isn't working label Sep 7, 2022
@ajcasagrande
Copy link
Contributor

ajcasagrande commented Sep 7, 2022

What is the output of the base call without the part that extracts the tokens?

curl -s http://host-ip:59882/api/v2/device/name/Camera001/Profiles | jq .

@Shadab995
Copy link
Author

it's showing this
{
"apiVersion": "v2",
"message": "request failed, status code: 503, err: HTTP request timeout",
"statusCode": 503
}

@Shadab995
Copy link
Author

for others it's working properly to get the device name , etc and it's not working for stream uri as well.
I use this command
curl -s http://host-ip:59882/api/v2/device/name/Camera001/StreamUri?jsonObject=ewogICAiUHJvZmlsZVRva2VuIjogInByb2ZpbGVfMSIKfQ== | jq -r '"streamURI: " + '.event.readings[].objectValue.MediaUri.Uri'' : it's returning Null value

@ajcasagrande
Copy link
Contributor

@Shadab995 Are you saying that other device commands that communicate with the camera are working? Getting device name sounds like an EdgeX command and not an Onvif command.

A 503 error code is typically something you get when the onvif device service is not able to communicate to the camera, or sends a command to the camera and does not get a response back. You say the services are running on an AWS EC2 instance. Where is the camera located? It needs to be accessible by the AWS EC2 instance for it to work properly. That means setting up port forwarding, using public ips, etc.

@Shadab995
Copy link
Author

Ok , I need to check that how to connect onvif camera on ec2 instance because the document uses localhost and not server.

do you have any idea or any documentation that I can follow to solve this issue ?

@lenny-goodell
Copy link
Member

@Shadab995 , are you running EdgeX and camera device service on ec2 instance and trying to connect to camera on a network the ec2 can connect to?

@Shadab995
Copy link
Author

For now I followed the tutorial as mentioned in the latest video of EdgeXFoundry for connecting a device-onvif camera. I bought the same model as well C200 generate the docker file first and replace “127.0.0.1” with “0.0.0.0” and assigned the required port numbers to the security group.

so , after running docker..
The edge-ui is running fine .
The commands to get the device name runs good.
The command to fetch the deviceprofile doesn’t work for me
And in the UI when I click on “try” to get the list of data , profiles and other details..it gives me 503 error.

@ajcasagrande
Copy link
Contributor

@Shadab995 It sounds like you are trying to access a camera connected to your local WiFi network via an instance of EdgeX installed in the cloud. This is not a currently supported deployment method. You can probably make it work, but it is not recommended for security reasons.

What you should do (if possible) is install EdgeX on a machine (or VM) that is within your same local network.

Here is the not recommended way of getting it to work through the cloud. This will open your camera up publically to the entire internet so be warned.

  1. Get your public ip address of your router. This can also be done by visiting various websites from a machine on your network. https://ipinfo.io/json
  2. Go into your router and port forward 2 ports, one going to port 2020 and another going to 554 of the local ip address of your camera.
  3. Configure the EdgeX device to use the external ip address you found in part 1 and the port you forwarded to port 2020 on your camera.

@Shadab995
Copy link
Author

Shadab995 commented Sep 11, 2022

Thank you sir.

Now , I am running Edgex on my local machine .

I followed that but then it gave me this error and I'm facing difficulties troubleshooting this.

can you please help me

code: 500 , message: request failed, status code: 500, err: {"apiVersion":"v2","message":"error reading DeviceResourece Profiles for Camera001 -\u003e failed to execute read command -\u003e invalid request for the function 'GetProfiles' of web service 'Media'. Onvif error: fault reason: Authority failure, fault detail: , fault code: SOAP-ENV:Sender ter:NotAuthorized ","statusCode":500}

@Shadab995
Copy link
Author

Hello ,

Any inputs please. it's really important for me

Thank you

@ajcasagrande
Copy link
Contributor

@Shadab995 That means that the username and password for the camera are incorrect.

Follow the video at https://youtu.be/vZqd3j2Zn2Y?t=200

@Shadab995
Copy link
Author

Thank you for the response but it's correct because i can connect my camera with those credentials to VLC media player using rtsp and it' working fine.

But , I'll try creating new credentials and redo the process again.

Sir is their anyy other suggestions apart from this that can help me ?

@ajcasagrande
Copy link
Contributor

@Shadab995 Go to consul and set Writable.LogLevel to DEBUG.

Also snoop around the InsecureSecrets folders to make sure everything is correct in there.

Send us some of the DEBUG logs after you try with the new password.

@Shadab995
Copy link
Author

Thank you for the support . I looked into log level and found out that the MAC address and Username and Password were not in strings and added ("") to them to make them strings and then used it..Finally got output for some information but for others and for getting the profile token it's still showing error.
Attaching the screenshots for better reference.

WhatsApp Image 2022-09-14 at 1 12 29 AM (1)
WhatsApp Image 2022-09-14 at 1 12 29 AM
WhatsApp Image 2022-09-14 at 1 12 27 AM

@ajcasagrande
Copy link
Contributor

@Shadab995 Can you provide us with the DEBUG logs of the docker services?

For example:

docker logs $(docker ps -qf name=device-onvif-camera) > /tmp/onvif_logs.txt

As far as the strings issue, that sounds suspicious, as I do not know why that would happen. In the consul UI, did you modify the values of InsecureSecrets? Because the consul UI has a tendency to try and format the value as json and will complain if it does not have quotes, however you do not want quotes in them.

The reason why some commands may work and others not, is that some commands do not require authentication. I do not know if the ones you called don't or not. Definitely the DeviceInformation one does require it.

Another thing you can try is to change your password on the camera. Maybe there is some special character it does not like.

@ajcasagrande ajcasagrande added question Further information is requested tapo Tapo Camera and removed bug Something isn't working labels Sep 15, 2022
@Shadab995
Copy link
Author

Hello @ajcasagrande

Yes , I changed the password and removed the special char as well.

Here is the log file for your reference.
onvif_logs.txt

It didn't gave me a response for DeviceInformation for gave it for MetaData.

Thankyou so much for the help. Highly appreciated

I brought the camera just after watching the above video so that it can be easily implemented and also gave the deadline to the people.

Hence I request your support and assistance in understanding the errors so as to complete this project.

Thank you

@ajcasagrande
Copy link
Contributor

@Shadab995 Yes it appears as though the credentials for the camera have not been properly configured within the system.

level=WARN ts=2022-09-14T22:41:38.3330915Z msg="failed to get credentials for camera Camera001, setting AuthMode to none for temporary client"
level=ERROR ts=2022-09-14T22:42:08.3328622Z msg="Failed to retrieve credentials for the secret path credentials001: Error, path (credentials001) doesn't exist in secret store"

Also, note that the quotes you added are messing up the values:

level=WARN ts=2022-09-15T20:29:36.4880022Z msg="Skipping invalid mac address \"28:87:BA:B1:B9:F2\": address \"28:87:BA:B1:B9:F2\": invalid MAC address"

At the root directory of device-onvif-camera, run:

Note: fill in the username and password with actual values. The other options should stay the same.

bin/map-credentials.sh -u "username" -p "password" -P "credentials001" -A usernametoken -M "28:87:BA:B1:B9:F2"

Another thing you can try is within the edgex-compose directory, run the make clean command to stop EdgeX and remove ALL DATA. Then you can start over following the video from the start.

@Shadab995
Copy link
Author

ok .. I'll do it . thanks a lot @ajcasagrande sir

@Shadab995
Copy link
Author

Thanks a lot @ajcasagrande sir , it helped me in setting the proper credentials and it worked fine but while using ffplay and using mplayer as well , i get the error like :

ffplay version 4.2.7-0ubuntu0.1 Copyright (c) 2003-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --prefix=/usr --extra-version=0ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared libavutil 56. 31.100 / 56. 31.100 libavcodec 58. 54.100 / 58. 54.100 libavformat 58. 29.100 / 58. 29.100 libavdevice 58. 8.100 / 58. 8.100 libavfilter 7. 57.100 / 7. 57.100 libavresample 4. 0. 0 / 4. 0. 0 libswscale 5. 5.100 / 5. 5.100 libswresample 3. 5.100 / 3. 5.100 libpostproc 55. 5.100 / 55. 5.100 Could not initialize SDL - No available video device (Did you set the DISPLAY variable?) ``

I am trying to solve this from past 2 days but it's not working fine. i installed all the dependencies and the required packages like
vlc , ffmpeg , build-essentials and not able to set the display variable as well.

Please help if possible .

thank you

@lenny-goodell
Copy link
Member

@Shadab995 , do you still need help with this?

@lenny-goodell lenny-goodell added the 1-low priority denoting isolated changes label Jan 25, 2023
@Shadab995
Copy link
Author

Yes please , it would be really good if ffplay can work in my system .

thank you

@lenny-goodell
Copy link
Member

@ajcasagrande , fyi.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1-low priority denoting isolated changes question Further information is requested tapo Tapo Camera
Projects
None yet
Development

No branches or pull requests

3 participants