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

What's the best way to share the model between two play framework application?
Java built in monitoring tool
Collapsing toolbar layout with recyclerview need to collapse based on recycler view height
How to log exception stack trace in Json object with out breaking with log4j2
Efficiency of sequential algorithm executed on machine with 60Gb RAM
Joda-Time Period Calculation
How to check if Current Hour falls between certain range
How to set alert cancel on Popup In selenium web driver
How to get all the keys of json in java using Gson or org.json library? [duplicate]
Can someone explain join method in Java Thread class?
Spring Boot PropertySources in test environment
How to get image source and description from html data using Jsoup
How to clear java.lang.IndexOutOfBoundsException in selenium webdriver
Java Reflection: Get type parameter of generic interface from implementation class
Start Spring Boot War in a tomcat instance
HDIV : I'm getting a NullPointerException when accessing a page

Categories

HOME
clips
cookies
tinymce
json.net
layout
view
include
mean-stack
routes
amortized-analysis
sqlite3
ojdbc
mvvmcross
in-app-purchase
upload
paradox
append
webrequest
amazon-cloudformation
php-7.1
orchardcms
decimal
clojurescript
graphlab
django-admin
facebook-page
footer
interop
sms-gateway
beyondcompare
samoa
firefox-webextensions
amazonsellercentral
accessor
core-text
claims-based-identity
tdd
intel-pin
kannel
bootstrap-material-design
windows-error-reporting
social-media
elasticsearch-ruby
media-queries
frame
nameservers
binary-data
uisplitview
exuberant-ctags
cloud-code
google-api-nodejs-client
bytecode-manipulation
revolution-slider
appfabric
jquery-bootgrid
gesture
vapor
opshub
unoconv
nomethoderror
mime
outlook-api
acoustics
multipeer-connectivity
celery-task
winscp-net
media-player
color-profile
dynamics-sl
visual-c++-2008
sts-springsourcetoolsuite
elements
dstu2-fhir
paypal-express
websitepanel
essence
php-internals
independentsoft
two-factor-authentication
security-testing
cakephp-3.1
microbenchmark
method-parameters
c++03
directoryservices
camanjs
gulp-less
heisenbug
p4java
picturefill
resty-gwt
mbr
sitemesh
spring-io
gwt-rpc
gridcontrol
seed
mqx
free-variable
e4x
typoscript2
funscript
getmessage
buildr
work-stealing
zpt
table-footer
appendto
w3wp.exe
asp.net-mvc-areas
brewmp
eqatec

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