Comments (10)
Hi @bubblesdev,
The simplest way to troubleshoot these issues is by using the included onvif
cli command that is included in the package. You can find the install and quick start for these in the README. Once you have the cli application installed and authorized you can run commands like the following to get a full debug of the request/response for your device.
# list profile tokens for your device with debug
onvif media1 get-profiles --log-level all
#just list the tokens (no debug)
onvif media1 get-profiles | jq -r '.[]."@token"'
#get the stream uri (wuth debug)
onvif media1 get-stream-uri --profile-token Profile_1 --log-level all
If you add the output to the issue, I can make suggestions or resolve any bugs.
Overall, the error that your getting means that the http connection has timed out in its attempt to connect to your device. So it's likely that the IP address and port combination you're using to connect is incorrect.
Also the above commands are primarily targetted at macos and linux users. The jq
utility can probably be installed on windows with chocolatey.
from easy_onvif.
![Screen Shot 2024-01-23 at 12 36 07](https://private-user-images.githubusercontent.com/73842287/298923140-d27cfaf5-b53b-4437-b517-6381ea7d6c4e.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM2MjA0MjUsIm5iZiI6MTcyMzYyMDEyNSwicGF0aCI6Ii83Mzg0MjI4Ny8yOTg5MjMxNDAtZDI3Y2ZhZjUtYjUzYi00NDM3LWI1MTctNjM4MWVhN2Q2YzRlLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA4MTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwODE0VDA3MjIwNVomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWNlZGUzZmQ4ZWI0NTJhNDVmNDhhNTAwMjkxMDNmMTczNDVmOTZlYjRhNGZiZTg4OGQ3MDAyZWYwMzJmYWQyMDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.XeMpZVoCp_cCMVQz3BWAKd251xTnSkJfEwhf_1VraQE)
I'm able to use the cli commands to fetch both snapshot and streamuri but doesn't work on the app as connections are refused and same errors above
from easy_onvif.
Hi @bubblesdev,
I assume by "app", you mean a Flutter app? Since the cli
command is running properly this means that the easy_onvif package works properly with your device. The likely issue in this case is the Flutter code you're using to connect to the device. Since I haven't seen the code, there's not a lot I can suggest.
from easy_onvif.
Here's the code below:
String? rtspUri;
VideoPlayerController? _controller;
bool connecting = true;
late Onvif onvif;
late final List profiles;
String? snapshotUri;
String url = '';
@OverRide
void initState() {
initialize();
super.initState();
// Initialize ONVIF connection (replace with your camera details)
}
Future initialize() async {
onvif = await Onvif.connect(
host: 'ipaddress',
// Replace with camera IP address
username: 'admin',
password: 'password!');
setState(() {
connecting = false;
});
}
Future _fetchStreamUri() async {
if (!connecting) {
try {
profiles = await onvif.media.getProfiles();
initializeVideoPlayer();
try {
if (profiles.isNotEmpty) {
snapshotUri = await onvif.media.getSnapshotUri(profiles[0].token);
print('Snapshot: $snapshotUri');
}
} catch (err) {
loggy.error(err.toString());
}
var media = await onvif.media.getProfiles();
var profileToken = media.first.token;
print('Profile: $profileToken');
try {
setState(() {
url = OnvifUtil.authenticatingUri(snapshotUri!, "admin", "password");
print('Snapshot URL: $url');
});
} catch (e) {
print('Error constructing snapshot URL: $e');
}
rtspUri = await onvif.media.getStreamUri(profileToken);
print('RTSP URI: $rtspUri');
// Start video playback
} catch (e) {
print('Error fetching stream URI: $e');
if (e is DioException) {
print('DioError details: ${e.type}, ${e.message}, ${e.error}');
}
}
}else{
print('Not connected!');
}
void initializeVideoPlayer() async {
if (rtspUri != null) {
_controller = VideoPlayerController.networkUrl(rtspUri! as Uri);
await _controller?.initialize();
await _controller?.play();
setState(() {
}); // Update UI to display video
}
}
Thank you for help!
from easy_onvif.
Flutter can be pretty tricky with it's use of Future
s. In your case your initialize()
method is returning before it's completed execution, due to it being an async
method.
Have a look at the Flutter
example that I've provided with the package. It might help you out - example.
from easy_onvif.
Thanks but I am still surprised that the getStreamUri still don't work after implementing your example and also the snapshotUri is fetched but doen't load as connection is refused, seems the uri is not in the right format:
I also tried futurebuilder and it is still same error :/
Here's a log report
` 21:45:48.468250 DEBUG - getStreamUri
[UI Loggy - LoggingInterceptors] 🐛 21:45:48.473820 DEBUG - URI: http://ipaddress:1091/Media2
[UI Loggy - LoggingInterceptors] 🐛 21:45:48.474655 DEBUG - REQUEST:
E/flutter ( 7892): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Exception: DioException [unknown]: null
E/flutter ( 7892): Error: HttpException: Connection closed before full header was received, uri = http://ipaddress:1091/Media2
E/flutter ( 7892): #0 Transport.sendRequest (package:easy_onvif/src/soap/transport.dart:51:7)
E/flutter ( 7892):
E/flutter ( 7892): #1 Media2.getStreamUri (package:easy_onvif/src/media2.dart:173:22)
E/flutter ( 7892):
E/flutter ( 7892): #2 Media.getStreamUri (package:easy_onvif/src/media.dart:256:11)
E/flutter ( 7892):
E/flutter ( 7892): #3 _MyHomePageState._initialize (package:onivf_app/stream_screen.dart:90:17)
E/flutter ( 7892):
E/flutter ( 7892):
[UI Loggy - LoggingInterceptors]
DioException [unknown]: null
Error: HttpException: Connection closed before full header was received, uri = http://ipaddress:1091/Media2`
from easy_onvif.
After updating to the recent version 2.2.0. The streamUri was fetched succesfully, but the rtsp can't be opened:
ibvlc demux: Failed to connect with rtsp://ipaddress:554/stream0?username=admin&password=password
E/VLC (20644): [b4000072193c7190/5675] libvlc stream: Failed to connect to RTSP server ipaddress:554
E/VLC (20644): [b4000072193c7190/5675] libvlc stream: cannot connect to ipaddress:554
E/VLC (20644): [b4000072193c7190/5675] libvlc stream: Connection failed
E/VLC (20644): [b4000072193c7190/5675] libvlc stream: VLC could not connect to "ipaddress:554".
E/VLC (20644): [b400007219740290/5675] libvlc input: Your input can't be opened
E/VLC (20644): [b400007219740290/5675] libvlc input: VLC is unable to open the MRL 'rtsp://ipaddress:554/stream0?username=admin&password=password'. Check the log for details.
Pls which video player can open the link
from easy_onvif.
Hi @bubblesdev ,
Did you manually update the log message to remove the IP address from the log?
rtsp://ipaddress:554/stream0?username=admin&password=password
This package will return the rtsp
uri from your device, anything after that is out of scope for thid project. For questions about errors from the VLC package should be asked there.
from easy_onvif.
Nah, i edited the ipaddress before commenting
from easy_onvif.
@faithoflifedev I on the other hand is getting DioException [bad response]: This exception was thrown because the response has a status code of 401 and RequestOptions.validateStatus was configured to throw for this status code.
from easy_onvif.
Related Issues (20)
- [2.1.0-dev11] error during onvif.getProfiles() device media1 HOT 2
- [2.1.0-dev11] error during onvif.getStreamUri() device media1 HOT 2
- [2.1.0-dev.14] onvif.mediaSupportLevel HOT 2
- Flutter example application cannot run successfully HOT 2
- RTSP port in the getStreamUri response not correct HOT 3
- camera recording HOT 2
- Is it possible to check if Onvif connect failed? HOT 2
- Onvif Imaging Profile HOT 3
- MulticastProbe with Auth HOT 3
- onvif discovery crash in windows HOT 6
- using CLI for testing causes a crash on onvif probe list-devices HOT 1
- Unable to get preset HOT 26
- new specifications support--thermal interface HOT 2
- How send audio stream to camera ? HOT 3
- Couldn't connect with Ezviz H8c camera HOT 3
- BUG: get-capabilities method is breaking for some cameras HOT 4
- BUG: Camera movement command is not working for some cameras HOT 16
- getStreamUri doesn't connect to sub stream of Onvif camera HOT 5
- Actions that require authentication no longer work HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from easy_onvif.