aarenson / PHPCap

PHP Classes for using the REDCap API
Apache License 2.0
16 stars 6 forks source link

Connect to Vandy's test server? #7

Closed wibeasley closed 7 years ago

wibeasley commented 9 years ago

Hey @aarenson (cc: @nutterb). This is related to https://groups.google.com/forum/#!topic/project-redcap-plugins/Re0zhF1aIlg.

Can you try to connect to Vandy's test server with your new library? These credentials should retrieve a very minimal PHI-free dataset.

token: "D96029BFCE8FFE76737BFC33C2BCC72E"
uri: "https://www.redcapplugins.org/api/"
----
record_id,name_first,name_last,address,telephone,email,dob,age,ethnicity,race,sex,height,weight,bmi,comments,demographics_complete
1,Nutmeg,Nutmouse,1002,,,,,,,,,,,,0

I'm still stumped. I've tried 2.5 libcurl-based libraries (not including mine & @nutterb's) and failed with no hints other than the SSL is failing (eg, Error in curl::curl_fetch_memory(url, handle = handle) : SSL connect error). Everything works with my OU servers. It's just this Vandy EC2 test server.

However, things are working with PostMan on Vandy's test server: image

I'm asking you for to try with PhpCap for two reasons. First, to hopefully get closer to a diagnosis or solution that's evaded @nutterb and me. Second, once we have multiple REDCap API libraries pulling from the same test server, it will be easier for the different packages to leverage each other's unit & integration tests (related to our conversation two or three months ago).

aarenson commented 9 years ago

When I try with PhpCap it looks like it is connecting, but there's simply no data to retrieve. The body returned is empty, but here are the headers returned:

header_array: Array ( [url] => https://www.redcapplugins.org/api/ [content_type] => [http_code] => 0 [header_size] => 0 [request_size] => 269 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.05312 [namelookup_time] => 1.4E-5 [connect_time] => 0.026519 [pretransfer_time] => 0 [size_upload] => 129 [size_download] => 0 [speed_download] => 0 [speed_upload] => 2428 [download_content_length] => -1 [upload_content_length] => 0 [starttransfer_time] => 0 [redirect_time] => 0.053165 [certinfo] => Array ( )

)

aarenson commented 9 years ago

The first thing I would check is whether or not the token we're using is correct. I'm not sure I can distinguish a result that's caused by having a bad token from a result that's caused by trying to access an empty project.

aarenson commented 9 years ago

I wonder if this issue has to do with verifying the cert of the server. Maybe the attempts that have worked haven't been verifying that cert.

... Except that I just checked and the code I was using had CURLOPT_SSL_VERIFYPEER set to FALSE.

wibeasley commented 9 years ago

I'm not sure I can distinguish a result that's caused by having a bad token from a result that's caused by trying to access an empty project.

I was hoping we could rule out those two possibilities (ie, and empty project and/or bad token) since Postman results the correct (tiny) dataset. Am I overlooking something?

wibeasley commented 9 years ago

I know very little about SSL and webserver administration. Does a test exist that can verify that a webserver's SSL mechanisms are working correctly (independently from the API)? Should we pose this last question to the REDCap plugin committee forum?

... Except that I just checked and the code I was using had CURLOPT_SSL_VERIFYPEER set to FALSE.

@aarenson, was that option set through PhpApi? I didn't think the cURL library was underneath your package too. (It is underneath the 2.5 different libraries available in R.) I was hoping that the PHP approach avoided curl, and did something else.

Chris Nefcy shared some C# code a few months ago. I doubt that stack has any trace of cURL. I'll see what that does on Wednesday.

aarenson commented 9 years ago

Let's see. That option was set by editing the file (RestCallRequest.php) provided by Vanderbilt for using the REDCap API via PHP. Let's see if I can determine if RestCallRequest.php relies on cURL ...

aarenson commented 9 years ago

Looks like it does. RestCallRequest.php uses the curl_init function (http://php.net/manual/en/function.curl-init.php).

aarenson commented 9 years ago

Let me dig up my notes from a couple years ago when I was trying to get SSL to work w/ LDAP and see if I can find a simple test to check if a website's cert seems to be working properly ...

aarenson commented 9 years ago

Using 'openssl s_client -connect :443 I see virtually identical results in the cert information between what we have at IU and what Vanderbilt has. I seriously doubt this is related to a certificate issue.

I wonder if there is some sort of packet filtering going on that is blocking cURL somehow.

aarenson commented 9 years ago

Just for sanity's sake, I've tested the very same code against my development server here and it works. I also went and created my own project on the redcapplugins.org instance and tested against the new project. Same failed response as using your API token, and that response looks exactly as it did when I had a typo in the name of my dev server, which makes me wonder if this isn't somehow a DNS issue. I'm going to use dig to take a look at what records exist for redcapplugins.org.

aarenson commented 9 years ago

Using dig, I've discovered that the reverse DNS lookup on the IP address assigned to redcapplugins.org points to ec2-54-208-178-133.compute-1.amazonaws.com

So, there's a difference there, but I don't know if that's really an issue. I have done some testing with the following results:

URL= redcap-branch2-app.uits.iu.edu SUCCESS URL=[IP address of redcap-branch2-app.uits.iu.edu] SUCCESS URL=redcapplugins.org FAIL URL=ec2-54-208-178-133.compute-1.amazonaws.com FAIL URL=[IP address of redcapplugins.org] FAIL

I'm stumped.

wibeasley commented 9 years ago

@aarenson, do you have any objections about going to the plugin forums about this? Do you want me to start the thread, and you fill in what details I missed. Unless you'd like to start the tread, I'm thinking about opening it with

Then you can fill in that part. Or is there another approach you'd like to take?

aarenson commented 9 years ago
Happy for you to make the post and I'll follow up with any useful details I think of.

Andy

On Tue, Jul 07, 2015 at 02:04:19PM -0700, Will Beasley wrote:

@aarenson, do you have any objections about going to the plugin forums about this? Do you want me to start the thread, and you fill in what details I missed. Unless you'd like to start the tread, I'm thinking about opening it with

  • a summary that's similar to the first post of this issue,
  • a statement that your Php code works for your server, but not Vandy's
  • mentioning that you dug into network issues that I don't understand well

Then you can fill in that part. Or is there another approach you'd like to take?


Reply to this email directly or view it on GitHub: https://github.com/aarenson/PhpCap/issues/7#issuecomment-119340501

Andrew D. Arenson | aarenson (@) iu.edu Advanced Biomedical IT Core, Research Technologies, UITS | W (317) 278-1208 RT is a PTI Cyberinfrastructure & Service Center | C (317) 679-4669 Indiana University Purdue University Indianapolis | F (317) 278-1852