SafeTrace icon indicating copy to clipboard operation
SafeTrace copied to clipboard

findMatch function returns error

Open cmalfesi opened this issue 5 years ago • 8 comments

@lacabra Woking on the frontend I'm receiving an error. Using curl get also an error. I have checked the documentation and curl -H "Content-Type: application/json" -d '{"method":"findMatch","jsonrpc":"2.0","params":{"encryptedUserId":"e8e7c1971b7bdb8d9d78df1b8b88f60f731f08688e47731f530df90756c07dbfdc8c9ca048c26f055843a0f1f07cc68d7700ad7b","userPubKey":"7b2d957d4fa5682067aeebdaee6c34e640e4ce4ae4f803f3f44bbbd95a50b4eecad0fbdc5c3e6c3879ac42249ddc71ecadaf45415588f0347c5c7b2f3a360d48"},"id":"dc4d0812-5e62-4607-8b5d-409eaca38ec4"}' https://safetrace.enigma.co

Error result: image

This is the error on the frontend: image

It is related to this PR #50

cmalfesi avatar Apr 15 '20 11:04 cmalfesi

Thanks @cmalfesi for your report. I'm looking at this right now, and so far I can confirm that the server is up and running, and responding correctly to requests

lacabra avatar Apr 16 '20 17:04 lacabra

@cmalfesi You are seeing two different errors here:

There is an error with the curl request that I am investigating. It causes a segmentation fault on the enclave, which then restarts, and results in the Bad Gateway that you are seeing, because the upstream server fails. This is not the error that we want to focus on here...

If you look at the Javascript code in the client/ folder, there is a script for to call findMatch, which works just fine. In your frontend code, the analogous requests fails because of CORS. This is the relevant error that we should tackle. I am curious: you should be seeing this same error for addPersonalData, is this correct? I would be surprised if you only see this error for findMatch. Can you please confirm?

lacabra avatar Apr 16 '20 17:04 lacabra

@lacabra I share here a small video that shows the steps and what endpoint is returning a problem. Video of running frontend

Regarding the Javascript code in the client/, we were using that version but I had the CORS problem calling the endpoint 'addPersonalData' when with Curl it was working perfect, that is why I have improved the code and suggested to Alaa a new version of this file. Updated enclave.js

cmalfesi avatar Apr 19 '20 13:04 cmalfesi

@lacabra Do we need to add the CORS header on the server for this?

assafmo avatar Apr 19 '20 13:04 assafmo

@assafmo CORS is set up here, and as per documentation, these are the defaults, which set origin="*" which should accept requests from any domain. If we modify this code, ping me, and I will push the changes to the server to reload the live instance.

I have tested it with curl and Javascript client code (for example here), and they work fine.

lacabra avatar Apr 19 '20 16:04 lacabra

Cool, thanks. No plans to change the code for now. @cmalfesi Sorry so I don't get it... Why and where you are seeing CORS errors?

assafmo avatar Apr 19 '20 17:04 assafmo

@assafmo AS I have shared on my video on this comment, when I try to use findMatch in the frontend, it returns CORS error.

This is called after upload my location file and try to show the results. ../UIcode/src/Pages/Results/index.jsx

Some days ago, we had the same problem with the endpoint addPersonalData, but it was solved changing the way to use async and await functions in React. I tried the same solution for findMatch, but I still have the same Cors error.

I will try to fix again on Monday.

cmalfesi avatar Apr 19 '20 22:04 cmalfesi

@lacabra I was trying to fix the CORS problem when I call the findMatch in the React frontend, but I couldn't get it working well. I have tested your javascript script from ../client/index.js and it works good only with your example. If I try to run it with the id user hash value it doesn't work well.

Here the example using the hash value created from the email users: image

Error: image

If I back the parameters to the original values, then it works again.

FYI: I'm using this enclave server for my tests const JSON_RPC_Server='https://safetrace.enigma.co';

Can you tell me if I'm doing something wrong?

cmalfesi avatar Apr 21 '20 08:04 cmalfesi