java


Streaming a webcam to a nginx server from Java


I'm trying to stream my webcam to a nginx server from Java using the Webcam Capture Live Streaming Example from Sarxos Webcam Capture API.
So, in Java i have the following code:
Webcam webcam = Webcam.getDefault();
String host = "<nginx server IP>";
int port = 2202;
WebcamStreamToServer webcamStreamToServer;
webcamStreamToServer = new WebcamStreamToServer(webcam, host, port);
webcamStreamToServer.start();
and
class WebcamStreamToServer extends Thread {
...
#Override
public void run() {
StreamServerAgent serverAgent = new StreamServerAgent(webcam, size);
try {
SocketAddress socketAddress = new InetSocketAddress(host, port);
Socket socket = new Socket();
socket.connect(socketAddress);
serverAgent.start(socketAddress); // <-- here i get the exception
} catch (ChannelException ex) {
Logger.getLogger(WebcamStreamToServer.class.getName()).log(Level.SEVERE, null, ex);
}
}
....
}
nginx RTMP server is set up to listen on port 2202, and as I can see there is a connection in the ESTABLISHED state from my Java app as long as it runs (even after the following exception is raised):
root#nginxServer:/usr/local/nginx/conf# netstat -an | grep 2202
tcp 0 0 0.0.0.0:2202 0.0.0.0:* LISTEN
tcp 0 0 <nginx server IP>:2202 <java app IP>:62502 ESTABLISHED
The problem is that my Java app throws an exception when it tryes to start the serverAgent with the following message:
org.jboss.netty.channel.ChannelException: Failed to bind to: /<nginx server IP>:2202
at org.jboss.netty.bootstrap.ServerBootstrap.bind(ServerBootstrap.java:301)
at us.sosia.video.stream.agent.StreamServerAgent.start(StreamServerAgent.java:70)
at svchost.WebcamStreamToServer.run(WebcamStreamToServer.java:55)
Caused by: java.net.BindException: Cannot assign requested address: bind
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:437)
at sun.nio.ch.Net.bind(Net.java:429)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)
at org.jboss.netty.channel.socket.nio.NioServerBoss$RegisterTask.run(NioServerBoss.java:193)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:367)
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:291)
at org.jboss.netty.channel.socket.nio.NioServerBoss.run(NioServerBoss.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Anyone can point me to the right direction to find out why Java fail to bind on the nginx server IP/port?

Related Links

Delete specific HTML tags in String
How to mock method parameter in Mockito
Table not found error in h2 using hibernate3
Access Report from p:menuitem
Eclipse commands in java code
Add regex matches together
$Class.getResource failed from fat jar packed by maven shade plugin
Java ThreadPool that allocates work by thread name
jackson jersey json : serializing date from java to json
findViewById problems for webview in navigation drawer
For loop how to print to console without leaving on first iteration java
Dispatcher servlet throws exception: NumberFormatException
Overriding equals method to accept doubles inside of Object class. Java
Line break between GWT widgets
How to set shift in String.format dynamically? [duplicate]
Java audio doesn't play in jar file

Categories

HOME
jdo
gitlab
asp.net-core
gerrit
angular-material
routes
amazon-ecs
rubygems
flyway4
handsontable
serverless-framework
opentracing
beyondcompare
accessor
mmap
zurb-foundation-6
lcd
android-widget
react-css-modules
jaxb2
gsoap
junit5
ghost4j
wallpaper
normal-distribution
nssegmentedcontrol
overlap
espeak
user-controls
graphenedb
sas-visual-analytics
mesos-chronos
ensembles
node-gyp
android-mediaprojection
fakeiteasy
keydown
vao
react-scripts
python-webbrowser
powercli
mplayer
brightcove
nativeapplication
media-player
python-cryptography
cudafy.net
query-performance
passport-google-oauth
database-optimization
firebaseui
fputcsv
markojs
react-native-listview
prettytensor
superstack
rvest
php-internals
goose
javax.sound.midi
eclipse-clp
metaclass
wordml
responsive-images
sysinternals
method-parameters
javax.mail
bigbluebutton
fscommand
jquery-layout
doskey
jboss-weld
chronoforms
dmoz
coderush
javaspaces
hosts-file
getmessage
buildr
external-accessory
psi
floating
telerik-scheduler
visitor-statistic
sortable-tables
xsdobjectgen
ti-dsp
adrotator
data-driven
temporal-database
multiple-languages
.net-1.0

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App