Open p10tyr opened 3 days ago
I have configured a bare metal Ubuntu LTS and installed node and followed the instructions.
I created the bridged VLAN and still get the same error?
When i try to create config I get an interesting message?
piotr@ubuntu:~/onvif-server$ node main.js --create-config
Onvif Server: 192.168.1.187
Onvif Username: video
Onvif Password:
Generating config ...
Error: Optional Action Not Implemented
Failed to create config!
Hello,
Same error Failed to find IP address for MAC address a2:a2:a2:a2:a2:42
here with a configured macvlan :
6: c4-onvif@ens18: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether a2:a2:a2:a2:a2:42 brd ff:ff:ff:ff:ff:ff
inet 10.0.0.77/24 brd 10.0.0.255 scope global dynamic c4-onvif
I even ran dhclient c4-onvif
and got the correct response from my dhcp server.
IP responds to pings.
Docker running on a Debian 12 vm.
Any idea what the problem is? I really want this to work. onvif-server seems to be the perfect missing piece ;-)
I have been debugging (more like learning) the code on what its trying to do on an Ubuntu machine I setup just for all this to run natively as node from source.
I think its saying IP not found in this instance on the vlan mac because it cant connect to the camera.
If you try and follow the connect to docker instance and try and run the node main.js --create-config
what result do you get?
--edit--
Nevermind. dont use create-config. In the readme it says use RTSP you need to create the config manually. This create config is to connect to an onvif device and dump out its config.. not sure what the use case is there.
--edit--
I am looking at the source code and that method does
let client = await soap.createClientAsync('./wsdl/media_service.wsdl', options);
client.setEndpoint(`http://${hostname}/onvif/device_service`);
client.setSecurity(new soap.WSSecurity(username, password, securityOptions));
My camera is not onvif.. so I am confused why its trying to connec to to an onvif endpoint. Trying to query that via postman has no results..
So the problem with IP Address not found is something to do with Node not returning the VLAN
> ip addr
1: lo: <LOOPBACK,UP,LOWER_UP>
2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> state UP
link/ether 74:d4:35:9b:9e:68 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.108/24 metric ....
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> state DOWN group default
4: onvif-proxy-1@enp2s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether aa:aa:aa:aa:aa:a1 brd ff:ff:ff:ff:ff:ff
While debugging code
It does not seem like the VLAN state is UP so its not coming back.
OK !
We forgot to run the critical command
sudo ip link set onvif-proxy-1 up
Now it is showing in the get interfaces :D
But I only get IPv6 address no IPv4
Hello P10tyr !
Have you configured your dhcp server to give an IP to this Mac address ? I did it, I have a correct IP but still the same error if you saw my message above. Unfortunately...
I am using Unify UGC-MAX .. There are not many options there I thought it would just give it an IP?
Found it I had to add the IPv4 Manually under Fixed
but still no IPv4 showing in ip addr
In your Unifi Network, Settings, Network, your network, DHCP mode is DHCP Server ?
If yes : Clients Devices, in top right icon to add a client, and there you can add a lease for a Mac address.
Same problem now....
I removed and added it back to Unify the way you said. But it is not showing up any where in the list now. I cant see the MAC. When I try to add it.. it says the MAC already exists...
Client devices, Offline : here you can normally see the leases.
OK I re added it again and gave it static. I made the link UP. but its like its not working
In the docker host or machine where is set the macvlan : dhclient onvif-proxy-1 ip addr will show the IP given by the DHCP server.
I'm stuck there.
OK. I ran the dhclient on my machine where I have the server code and vlan and now it shows an IPv4 address. That is interesting why it not connect to unify dhcp? (im not sure what dhclient is)
But that now makes the interface come back with IPv4 in the code
And that progresses the code now
Starting virtual onvif server for Bullet1 on 192.168.1.12:8081 ...
I also found you can pass in debug arg (-d)
Starting virtual onvif server for Bullet1 on 192.168.1.12:8081 ...
Started!
Starting tcp proxy from port 8554 to 192.168.1.187:554 ...
Started!
Starting tcp proxy from port 8580 to 192.168.1.187:80 ...
Started!
Looks like it is now running?
👁️ 👁️
It has "detected" two cameras for some reason But one of them is the old camera with no ONVIF!
But it is having problems with live feed. Doesn't seem to be streaming
The default config file as high and low quality feeds
onvif:
- mac: aa:aa:aa:aa:aa:a1
ports:
server: 8081
rtsp: 8554
snapshot: 8580
name: Bullet1
uuid: ae426b06-36aa-4c89-84fb-7a6eb15ff734
highQuality:
rtsp: /Streaming/Channels/101/
snapshot: /Streaming/Channels/1/picture
width: 2048
height: 1536
framerate: 10
bitrate: 3072
quality: 4
lowQuality:
rtsp: /Streaming/Channels/102
snapshot: /Streaming/Channels/1/picture
width: 640
height: 480
framerate: 6
bitrate: 512
quality: 1
target:
hostname: 192.168.1.187
ports:
rtsp: 554
snapshot: 80
Thats the settings i have
i think the snap shot one needs to have ISAPI in it.. but this server does not support it yet anyway
dhclient is used to retrieve the ip address from the dhcp server
You're luckier than me ! I still have the same problem with Docker. Maybe time to switch to a bare metal installation as well...
Yea there is something not quite correct in docker. Maybe you need to create virtual interfaces using docker networks instead? Its connected now. yea. but its not streaming very well
And I understand now. Each feed is like a separate camera. ill just make 1 feed
Okay. You're right, the problem actually comes from docker's network configuration.
On the docker host :
docker network create -d macvlan -o parent=ens18 macvlan0 --subnet 10.0.0.0/24 --gateway 10.0.0.1
10.0.0.0/24 is my physical network, ens18 is the name of the interface in the docker host
Then :
docker run -d --rm -it --network macvlan0 --mac-address=a2:a2:a2:a2:a2:42 --ip=10.0.0.77 -v /etc/onvif-server/config.yaml:/onvif.yaml ghcr.io/daniela-hase/onvif-server:latest
a2:a2:a2:a2:a2:42 is the mac address for this camera in my config.yaml and 10.0.0.77 is the IP address of the onvif stream that Unifi Protect will see.
To check the correct assignment of the IP to the container you can do :
docker network inspect macvlan0
Now it works and I was able to adopt a third-party camera that did not provide an onvif stream, only rtsp/H264. I hope this can help those who want to use docker.
Nothing serious but just a little oddity : apparently the name provided in the config.yaml is not taken into account. Unifi Protect sees a "Cardinal" camera.
Thank you Daniela for your work !
Ahh thats great news and it maybe a bit simpler doing it the docker network way rather than the linux commands.
In Edge the live stream is a bit choppy but in the Protect app its smooth. Also the recording works fine and scrubbing is good!
I am going to try and create a PR with some improvements around the errors and descriptions of what's going on around the networking stuff.
I will also see if there is a way to rename the "Cardinal" on a PR
As I fix an ip to the container, my workaround will only work with one stream per docker. It's ok for me who only needs to encapsulate one stream. Otherwise it will be necessary to multiply the containers if we have several cameras.
This is not really a solution in my opinion.
You can connect multiple networks to docker 😄
As I fix an ip to the container, my workaround will only work with one stream per docker. It's ok for me who only needs to encapsulate one stream. Otherwise it will be necessary to multiply the containers if we have several cameras.
This is not really a solution in my opinion.
You may have been correct with this comment! I ran into limitations with assigning multiple MAC addresses to each node.
I did spend some time since yesterday doing a whole bunch of fixes.. which I have now made in my own forked repo. I have also merged the fixes to camera name and some better debug outputs.
Generally I am going to be focusing on making it work with docker compose there. It works nicely without any extra commands and if you want multiple streams.. yes multiple nodes .. for now! Will work to maybe remove the MAC address stuff completely.
Make sure the Docker container can access the correct network. You can use Docker's macvlan network mode to put the container in the same network as the host. Make sure you create the correct macvlan network and the container can get an IP address.
Seeing that you are using docker, I would like to recommend Servbay to you, which is more professional and easy to use on Mac than docker and homebrew
I solved the problem in Docker and it now auto registers MAC and IPv4 based on config entries.
It is also more performant network driver.
Firstly, I wanted to say thank you for creating this! Means I can carry on using some of my older, perfectly working cameras in Unify Protect now!
The docker instructions says
All you need to do is to mount your config.yaml to /onvif.yaml inside the container.
Which I have done. The mac address I used is the camera mac.. but i also tried a random one got the same response.
I am running Docker in Windows as test for now. But do i need to setup virtual networks too? I am not quite sure what is going on here.