Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Message and file not working all time #32

Open
sandipchandra17 opened this issue Jul 7, 2020 · 58 comments
Open

Message and file not working all time #32

sandipchandra17 opened this issue Jul 7, 2020 · 58 comments

Comments

@sandipchandra17
Copy link

sandipchandra17 commented Jul 7, 2020

  1. I followed the steps receive msg->send msg but getting different errror in different times though my connection is well formed between two mobile.
    I attached screenshots
    Screenshot_20200708-001816_PassOn

20200708_002409

2nd issue: file not received sometimes and damagrd file or half file received
20200707_011823
20200707_004327

@kirillzyusko
Copy link
Owner

kirillzyusko commented Jul 7, 2020

It seems like some data is missing. I think it's race condition (where you start sending file before actual receiving). That's why some files may look like corrupted.

Try to add delay before sending file. I think ~300ms is enough.

@sandipchandra17
Copy link
Author

sandipchandra17 commented Jul 7, 2020

300ms is not working.
Also after 3secs i am geeting error as below
Screenshot_20200708-011057_PassOn

Sometimes long waiting its working but no guarantee sometimes this error is coming..

@kirillzyusko
Copy link
Owner

Can you share your code?

@sandipchandra17
Copy link
Author

Dear Kirill,

I have sent my app.js via gmail to your gmail.. please check.

@kirillzyusko
Copy link
Owner

@sandipchandra17 You sent me almost identical code from my example project. Which flow isn't working there?

@sandipchandra17
Copy link
Author

sandipchandra17 commented Jul 8, 2020

As i told different types of error like below scenario:

  1. Testing in two mobile android 9 and another android 6.
    Clicked receive msg in receiver mobile -> clicking on send messege on sender mobile, its saying files successfully received in receiver mobile but nothing received.
  2. Sometimes clicking on send msg from sender mobile and receiver mobile received as exif in alert. Screenshot attached.
  3. Send msd>receive msg sucessful and receive file fine but after that when clicking send file msg successfully received but file received damaged or half file.
  4. If first time connect issue occurs then nothing will happed msg or file send.. i have to again remove group then problem solved but have to wait for long time but no gurantee above points occuring almost 80% case.

@kirillzyusko
Copy link
Owner

  1. I think it's impossible. "successful" means no error occurred in Java code. So file should be in a place.
  2. It seems, like stream of bytes was interrupted or you are trying to send the message not in UTF8. I need to have a look on Java logs. I can not say anything without them.
  3. That would be nice if you could re-create this scenario in code. By promise chaining. In this case I can reproduce it. During my testing everything worked fine.
  4. If you can not connect, then it's no sense to try to send messages/files. Or I misunderstood the description.

To sum it up: that would be nice, if you could share real example of code. Right now it sound too abstract and I can not even reproduce these issues. As a result I can nit help you nevertheless I want...
So sharing code snippet would be really nice.

@sandipchandra17
Copy link
Author

sandipchandra17 commented Jul 8, 2020

This is the same code i sent you in gmail.

  1. In this scenario why received file message would come when i click on send messge. It should come as message received successfully.
  2. I am sending normal string message if you can look my code send message method.
  3. Sometimes its working fine sometimes not may be time gap issue.. but in real life application how do i know what time i have to put..
  4. Agreed. I will check again using debug mode.. may be same time gap issue.
  5. Found another issue: group formed sucessfully but while sending msg getting the below error:
    Screenshot_20200709-002407_PassOn

@kirillzyusko
Copy link
Owner

The code that you sent me presented in format button -> handler. You haven't provided a full history of all actions that you performed/buttons that you pressed. I am asking for small piece of code. Can you create your own button (like "Reproduce Issue 1") and make handler for it, where I will see all methods, which you are calling and the order of these methods?

@sandipchandra17
Copy link
Author

Sorry I dont get your point.. what do you mean by firmat button-handler. I am testing same file you provided in the site..
My scenario is I have generated apk file from that code and installed in two mobiles. Then the process you mentioned I am doing

@kirillzyusko
Copy link
Owner

When I tested everything was fine, even with multiple message sending.
At least you are trying to send messages two times, right?
Can you put this business logic into separated function, and create special button for calling this method?
And provide this code here?

@sandipchandra17
Copy link
Author

sandipchandra17 commented Jul 8, 2020

I havnt started any logic on your code yet.
What I did is single click on below button clicks on the same code app.js you provided.. I dont know you tested but i am testing same code below scenario.

My steps only one click:
Create group in mobile 1
Investigate in mobile 2
Connect in mobile 2
Receive message in mobile 1
Send message in mobile 2 --- giving above errors exif and sometimes no msg received..in apk app is closing.
Receive file in mobile 1
Send file in mobile 2- sometimes ok sometimes corrupted file received sometimes nothing happens somtimes coming ????? Exif.

Is the java code having some timegap issue or android version before 9 not supported?

@kirillzyusko
Copy link
Owner

Hm, did you call getConnectionInfo after connection established?

@sandipchandra17
Copy link
Author

sandipchandra17 commented Jul 9, 2020

Yes I checked connection info and it was fine..
Today I tested again with some more time gap between steps and its working fine.. but how come end user will know how much have to wait..
So what I was thinking Is it possible from your java classes return some messages like when receive message arrived successfully in receiver mobile, sender will be notified so that app will allow him/her to proceed for file upload.. or if one file is still tranferring sender and receiver can get transfer status so that app can restrict to do further action until its finish operation through react native..

And another point can you please check in java classes as i dont know much java why sometimes send message giving " file received successfully" message. Is it same method used for both file and message.. I found this when the scenaio like if a file received half like damaged file then if i click receve msg->send message it is occuring..

@kirillzyusko
Copy link
Owner

kirillzyusko commented Jul 9, 2020

Hi @sandipchandra17
In fact your message gave me one interesting idea, why it may happen.
If I try to fix one bug and give you a branch (I won't publish these changes in npm but you will be able to install it from github) - can you test it and say, whether bug is persist?

Can you say, between which steps the increasing of time gap helped?
If it was after sendMessage/sendFile/receiveMessage/receiveFile, then probably I know where is the problem and have some ideas how to fix it. But I need your help in this case.

@sandipchandra17
Copy link
Author

Ok I will test this more minutely.. will let you know..

@sandipchandra17
Copy link
Author

I was thinking the point that rather than increasing time can we have live status exposed to both sender and received about message send to receiver or not informed to sender and file is downloading status to both sender and receiver and how much data is remaining. I don't know its possible or not just I thought.

@kirillzyusko
Copy link
Owner

@sandipchandra17 It can be possible. I can emit event when part of data has been transferred successfully.
But promises model is informing us about that. When promise is resolved -> data transferring is ended.

To be honest I saw the time difference between 'File received successfully' and 'File sent successfully:' ~300ms, when I transferred file ~10mb. I can not understand the cause of this delay, but I have several assumptions why it may happen. I see next:

  • async RN bridges;
  • network delays.

Apart of this I noticed, that sockets are closing after promise resolving. I think it's also incorrect and it may be a cause of damaged file. And I want to fix the socket closing. But I can not test my changes.
That's why I am asking you to help me with it.

@sandipchandra17
Copy link
Author

Yes I will test it.. let me know once you are done.

@kirillzyusko
Copy link
Owner

Discovered one problem. I'll try to fix it.

@sandipchandra17
Copy link
Author

sandipchandra17 commented Jul 10, 2020

If possible please emit transfered byte and total bytes or in kb so that it can be shown in progressbar to sender and receiver using react native..

@kirillzyusko
Copy link
Owner

Small update: my laptop has died😔
I'm going to send it to the service center within next few days (two days I hope).
Hope they can fix it quickly.

@sandipchandra17
Copy link
Author

Oh sad.. wish it recover soon..

@sandipchandra17
Copy link
Author

Hi Kirill,

Need one clarification:
Is this library support that sender can connect with multiple receiver and send same files to all receivers at the same time.
Or this feature not currently included?

@kirillzyusko
Copy link
Owner

Need to test it :)

@sandipchandra17
Copy link
Author

Another two questions and one observation:

  1. Is it possible to get own device name.
  2. Is it possible for receiver know the device name of which sender connected. Because from group info its not clear.
  3. Observation: when receiver successfully remove group but after long time later group info updated to sender means null.
    Is it normal as wifi direct taking time for this update or bug?

@kirillzyusko
Copy link
Owner

kirillzyusko commented Jul 13, 2020

  1. After enabling WiFI you should receive THIS_DEVICE_CHANGED_ACTION. According to this answer there should be info that you need.

For 2-3 I will have a look later, when my laptop will be repaired.

P. S. don't mix your issues into one place. Feel free to create different issues :)

@sandipchandra17
Copy link
Author

Created 3 issues #34, #35 and #36

@Rk-choudhary-ck
Copy link

Hii
i am facing the same problem in my project. when i click on send message i will face this problem. please tell me what should i do? and one thing more i don't know how i test my code because i'm running my project on real device. it is connect with multiple wifi connections but message not send . just i used the code from github with no changes . can i need to change any part of my code so my message or file send successfully.
please help me.

@kirillzyusko
Copy link
Owner

@Rk-choudhary-ck The problem above was happening because sendMessage method was calling several times. Could you describe your steps more precisely? How many devices do you have? What is the error do you get? Which steps are you doing?

@kirillzyusko
Copy link
Owner

Hi @Rk-choudhary-ck
Did you follow this instruction?
Are you sure, that you completed 3d item in this list?

@Rk-choudhary-ck
Copy link

Hii Kirillzyusko
yes i following these instructions but i get a error about fail connection the error is :
Error while message sending [Error: failed to connect to /192.168.49.1 (port 8988) from /192.168.49.1 (port 38749) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)]

@kirillzyusko
Copy link
Owner

kirillzyusko commented Oct 12, 2020

[Error: failed to connect to /192.168.49.1 (port 8988) from /192.168.49.1 (port 38749) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)]

@Rk-choudhary-ck When this error happens?
Could you send adb logcat logs as well?

P. S. it's worth to look at #26

@Rk-choudhary-ck
Copy link

i think it's no about logcat because it will happen in case when i send message .

@kirillzyusko
Copy link
Owner

I was asking for logs from logcat in order to understand where is the error happens...
Without logs from device I can not say anything, unfortunately.

@Rk-choudhary-ck
Copy link

Hii kirillzyusko
now i am face in log this kind of error.
LOG Error while file sending [Error: failed to connect to /192.168.49.1 (port 8988) from /192.168.49.1 (port 35053) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)]

@kirillzyusko
Copy link
Owner

@Rk-choudhary-ck I can not help unless you provide adb logcat output. You give me only final exception. But I can not understand what is the reason of this exception. Maybe it's permission issues. Maybe something another. I don't know. That's why I ask you to give me logs from your device.

@Rk-choudhary-ck
Copy link

Thanks Kirillzyusko

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 22, 2020 via email

@kirillzyusko
Copy link
Owner

Hi @Rk-choudhary-ck
Can you please give an example of path that doesn't work?

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 22, 2020 via email

@kirillzyusko
Copy link
Owner

Hi @Rk-choudhary-ck
Please, have a look on this thread
Your path contains symbols like %3A. You should convert them to plain chars.

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 22, 2020 via email

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 22, 2020 via email

@kirillzyusko
Copy link
Owner

kirillzyusko commented Oct 22, 2020

What is the path RNFS.DownloadDirectoryPath looks like?

Also why content://com.android.providers.media.documents/document/audio%3A34349 was converted to content://com.android.providers.media.documents/document/audio:3A34349? Shouldn't it be content://com.android.providers.media.documents/document/audio:34349?

And please @Rk-choudhary-ck - don't mix different issues. Feel free to create new one ;)

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 23, 2020 via email

@kirillzyusko
Copy link
Owner

@Rk-choudhary-ck you missed a slash. It should be /storage/emulated/0/Download/.

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 23, 2020 via email

@kirillzyusko
Copy link
Owner

kirillzyusko commented Oct 23, 2020

@Rk-choudhary-ck if you want my help, then, please, attach adb logcat logs for both devices. For sender and for receiver.

And please, create new issue. Your problem doesn't seems to be correlated with described above.

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 24, 2020 via email

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 26, 2020 via email

@kirillzyusko
Copy link
Owner

kirillzyusko commented Oct 26, 2020

@Rk-choudhary-ck well, first of all - you attached JS logs/logs from metro bundler. It's not sufficient information and I can not tell anything from this logs. Secondly - your problem is that you can not properly use two libraries together (react-native-document-picker and react-native-wifi-p2p) and it's not related to this issue (the problem in this issue is that sending multiple files with short delay is a cause of broken files).
So, PLEASE, create new issue and attach adb logs. Here is a brilliant article how to do it, but I'm pretty sure you can find a lot of other.
I will ignore any new posts here that are not related to the problem described in the first post of this thread.
Thanks in advance.

@Rk-choudhary-ck
Copy link

Rk-choudhary-ck commented Oct 26, 2020 via email

@kirillzyusko
Copy link
Owner

@Rk-choudhary-ck please, create a new issue.

@ChandanBeraTechno
Copy link

ChandanBeraTechno commented Jul 8, 2022

Hii kirillzyusko,
now i am face in log this kind of error in react native.
Error: Error while message sending [Error: failed to connect to /192.168.49.1 (port 8988) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)]

SYSTEM LOG:

LOG You can use the p2p mode
LOG startDiscoveringPeers status: success
LOG Running "BobakWifiDDemo" with {"rootTag":1}
LOG You can use the p2p mode
LOG startDiscoveringPeers status: success
LOG OnPeersUpdated [{"deviceAddress": "e6:46:da:85:bc:eb", "deviceName": "Redmi note 4", "isGroupOwner": false, "primaryDeviceType": "10-0050F204-5", "secondaryDeviceType": null, "status": 3}, {"deviceAddress": "0c:54:15:e6:39:6d", "deviceName": "INDLAPTOP333", "isGroupOwner": true, "primaryDeviceType": "7-0050F200-0", "secondaryDeviceType": null, "status": 3}]
LOG OnPeersUpdated [{"deviceAddress": "0c:54:15:e6:39:6d", "deviceName": "INDLAPTOP333", "isGroupOwner": true, "primaryDeviceType": "7-0050F200-0", "secondaryDeviceType": null, "status": 3}, {"deviceAddress": "ae:c1:ee:63:51:69", "deviceName": "Redmi note 3", "isGroupOwner": true, "primaryDeviceType": "10-0050F204-5", "secondaryDeviceType": null, "status": 3}]
LOG OnPeersUpdated [{"deviceAddress": "0c:54:15:e6:39:6d", "deviceName": "INDLAPTOP333", "isGroupOwner": true, "primaryDeviceType": "7-0050F200-0", "secondaryDeviceType": null, "status": 3}, {"deviceAddress": "ae:c1:ee:63:51:69", "deviceName": "Redmi note 3", "isGroupOwner": true, "primaryDeviceType": "10-0050F204-5", "secondaryDeviceType": null, "status": 3}]
LOG Group created successfully!
LOG THIS_DEVICE_CHANGED_ACTION {"interface": "p2p0", "networkName": "DIRECT-Ht-Android_abfa", "owner": {"deviceAddress": "e6:46:da:85:bc:eb", "deviceName": "", "primaryDeviceType": null, "secondaryDeviceType": null, "status": 4}, "passphrase": "6eu23hhL"}
LOG OnConnectionInfoUpdated {"groupFormed": true, "groupOwnerAddress": {"hostAddress": "192.168.49.1", "isLoopbackAddress": false}, "isGroupOwner": true}
LOG OnPeersUpdated [{"deviceAddress": "e6:46:da:85:bc:eb", "deviceName": "Redmi note 4", "isGroupOwner": true, "primaryDeviceType": "10-0050F204-5", "secondaryDeviceType": null, "status": 3}, {"deviceAddress": "0c:54:15:e6:39:6d", "deviceName": "INDLAPTOP333", "isGroupOwner": true, "primaryDeviceType": "7-0050F200-0", "secondaryDeviceType": null, "status": 3}]
LOG Connect to: {"deviceAddress": "e6:46:da:85:bc:eb", "deviceName": "Redmi note 4", "isGroupOwner": true, "primaryDeviceType": "10-0050F204-5", "secondaryDeviceType": null, "status": 3}
LOG Successfully connected
LOG OnPeersUpdated [{"deviceAddress": "e6:46:da:85:bc:eb", "deviceName": "Redmi note 4", "isGroupOwner": true, "primaryDeviceType": "10-0050F204-5", "secondaryDeviceType": null, "status": 1}, {"deviceAddress": "0c:54:15:e6:39:6d", "deviceName": "INDLAPTOP333", "isGroupOwner": true, "primaryDeviceType": "7-0050F200-0", "secondaryDeviceType": null, "status": 3}]
LOG OnPeersUpdated [{"deviceAddress": "e6:46:da:85:bc:eb", "deviceName": "Redmi note 4", "isGroupOwner": true, "primaryDeviceType": "10-0050F204-5", "secondaryDeviceType": null, "status": 0}, {"deviceAddress": "0c:54:15:e6:39:6d", "deviceName": "INDLAPTOP333", "isGroupOwner": true, "primaryDeviceType": "7-0050F200-0", "secondaryDeviceType": null, "status": 3}]
LOG OnConnectionInfoUpdated {"groupFormed": true, "groupOwnerAddress": {"hostAddress": "192.168.49.1", "isLoopbackAddress": false}, "isGroupOwner": true}
LOG getConnectionInfo {"groupFormed": true, "groupOwnerAddress": {"hostAddress": "192.168.49.1", "isLoopbackAddress": false}, "isGroupOwner": true}
LOG OnPeersUpdated []
LOG OnPeersUpdated []
LOG Error while message sending [Error: failed to connect to /192.168.49.1 (port 8988) after 5000ms: isConnected failed: ECONNREFUSED (Connection refused)]
LOG OnPeersUpdated [{"deviceAddress": "e6:46:da:85:bc:eb", "deviceName": "Redmi note 4", "isGroupOwner": true, "primaryDeviceType": "10-0050F204-5", "secondaryDeviceType": null, "status": 0}]

@kirillzyusko
Copy link
Owner

Seems like you can not establish a connection within 5s.
Why OnPeersUpdated reports empty array in the end?

viniciuscb added a commit to coletivoEITA/react-native-wifi-p2p that referenced this issue Mar 20, 2023
* ISSUE kirillzyusko#66
* also referenced in ISSUE kirillzyusko#32

Signed-off-by: Vinicius Cubas Brand <viniciuscb@gmail.com>
viniciuscb added a commit to coletivoEITA/react-native-wifi-p2p that referenced this issue Mar 21, 2023
* ISSUE kirillzyusko#66
* also referenced in ISSUE kirillzyusko#32

Signed-off-by: Vinicius Cubas Brand <viniciuscb@gmail.com>
kirillzyusko pushed a commit that referenced this issue Mar 21, 2023
…79)

* ISSUE #66
* also referenced in ISSUE #32

Signed-off-by: Vinicius Cubas Brand <viniciuscb@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants