Giter Club home page Giter Club logo

Comments (9)

pedroSG94 avatar pedroSG94 commented on June 17, 2024

Hello,

I'm not caching anything in the library. This seems a code error in your side.
I tested using 2 servers and alternate with both and all is working fine

Are you sure that the url is correct? Did you check the url set to the library each time to know the value when it fails? (check it when you call displayBase?.startStream(url) line)

from rootencoder.

mrdesai109 avatar mrdesai109 commented on June 17, 2024

Hey @pedroSG94 , I confirm that URL being passed to the library is correct. I am having a localhost RTMP server.
The issue is happening specifically when I change my Wifi connection of laptop. On changing the Wifi connection, the IPV4 address of the laptop will change, right?

So, on changing the Wifi connection the RTMP URL will also change. At this point, the library is not able to make connection the RTMP server. But, now if I uninstall and reinstall the app it actually connects and streams successfully. Why this behavior? Do you think it's my code side issue?

Here is the exact log -
192.168.1.8 is the changed IPV4 address of my laptop.
URL - rtmp://192.168.1.8:1935/live/test

Also I am making sure that laptop and Android device both are connected to new Wifi.

connection error
       java.net.SocketTimeoutException: failed to connect to /192.168.1.8 (port 1935) from /192.168.167.57 (port 32844) after 5000ms
      at libcore.io.IoBridge.connectErrno(IoBridge.java:190)
      at libcore.io.IoBridge.connect(IoBridge.java:134)
      at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:142)
      at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
      at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
      at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
      at java.net.Socket.connect(Socket.java:621)
      at com.pedro.rtmp.utils.socket.TcpSocket.connect(TcpSocket.kt:64)
      at com.pedro.rtmp.rtmp.RtmpClient.establishConnection(RtmpClient.kt:327)
      at com.pedro.rtmp.rtmp.RtmpClient.access$establishConnection(RtmpClient.kt:53)
      at com.pedro.rtmp.rtmp.RtmpClient$connect$1.invokeSuspend(RtmpClient.kt:237)
      at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)

from rootencoder.

pedroSG94 avatar pedroSG94 commented on June 17, 2024

Hello,

If you read the connection error you can check that you are not in the same network:

java.net.SocketTimeoutException: failed to connect to /192.168.1.8 (port 1935) from /192.168.167.57 (port 32844) after 5000ms

192.168.1.8 and 192.168.167.57 is not the same network. If you are the the same network the third number should be the same and only should change the last number.
The first one is your server IP as you said and the second one is your device IP.
The reason about if you uninstall the app and install again the app is working is maybe because you need wait a bit until your device get the correct IP.

from rootencoder.

mrdesai109 avatar mrdesai109 commented on June 17, 2024

@pedroSG94 That's a very good observation. I dint know that. Let me check why Android device is not getting the correct IP. I will get back to you as soon as possible.

from rootencoder.

mrdesai109 avatar mrdesai109 commented on June 17, 2024

@pedroSG94 I observed same thing is happening if I just turn off the Wifi, and reconnect my Android device to the same Wifi. The third digit becomes different.

failed to connect to /192.168.1.8 (port 1935) from /192.168.167.57 (port 55876) after 5000ms

It's only after I uninstall and reinstall the app, it will connect successfully.

As I noticed from the logs, that the library is using java.net.Socket() internally. Maybe problem lies there. Not sure.

      at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
      at java.net.Socket.connect(Socket.java:621)
      at com.pedro.rtmp.utils.socket.TcpSocket.connect(TcpSocket.kt:64)

Can you try to do this and let me know if you are facing the same issue as well?

  1. Connect to Wifi from Android device, and stream to RTMP server. Stop the stream.
  2. Turn Off Wifi of Android device.
  3. Turn On Wifi and connect to the same Wifi again, and try to stream.

from rootencoder.

pedroSG94 avatar pedroSG94 commented on June 17, 2024

Hello,

I haven't this problem.
Socket class is not related with your problem. I'm not using a class that can manipulate IP device or similar.

Try to reproduce the case using my app example to discard that it is an error related with your code. Also, you can check your current IP in the device settings to make sure that you are in the same network (wait until it is correct) and then click to start stream instead of automatize it.

If you have more than one router or wifi hotpots just shutdown all except one.
Also, you can configure your router to use always the same IP with your Android device and your server

from rootencoder.

mrdesai109 avatar mrdesai109 commented on June 17, 2024

@pedroSG94 It is happening with the example app too.

But I believe the issue is not related to library. I think on disabling and enabling Wifi, a different IP is assigned to Android device.

On disabling the Wifi and reconnecting to the Wifi, I can see the Android's IP is 192.168.1.2 in the Wifi settings. But when I try to connect to the RTMP server again, I still get the same error -

failed to connect to /192.168.1.8 (port 1935) from /192.168.167.57 (port 55236) after 5000ms

Definitely Android related issue, not the library I believe. I dont know how 192.168.167.57 is getting displayed. Also, as I mentioned earlier on doing uninstall and reinstall, connection is happening.

Any idea what is the root cause of this issue?

from rootencoder.

pedroSG94 avatar pedroSG94 commented on June 17, 2024

Also, as I mentioned earlier on doing uninstall and reinstall, connection is happening.

This has no sense for me. If you kill the app totally without uninstall, you should have the same result that uninstall app.

This feels like an error in your network configuration. I recommend you go to your router and configure a static IP to your Android device. Even a factory reset in your device could be a good idea.
Shutdown all devices that could be connected to your network except your server to avoid your router asign you other IP

from rootencoder.

mrdesai109 avatar mrdesai109 commented on June 17, 2024

Thanks @pedroSG94, I will try that. Closing this issue, since this is not a library related issue. Rather an Android side issue.

from rootencoder.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.