I was experimenting with this module, and could not make connection to Bittorrent Sync server (Ubuntu server 12.04 64-bit). It turned out, that there is php5-curl dependency, which in most cases might be present on hosting servers. But if you build your PHP stack manually, it would be good to indicate this dependency in README.txt or on module page.

Comments

Deciphered’s picture

Unfortunately, for a reason that I was not fully able to determine, Drupals http_get_request() system doesn't seem to be able to communicate with the BTSYnc API, which I really don't understand because it's just a REST client like cURL. But I did bash my head against the keyboard for about an hour on this, so that is the reason why cURL is currently being used.

You are absolutely right though, I should not make the assumption that cURL is always available, that's why drupal_http_request() is preferable because even if cURL isn't available it will still (usually) work.

I will look into this ASAP. And I will try to see if I can get drupal_http_request() to work as well, because I think that's extremely important.

P.S., I don't build my PHP stack manually, I believe cURL is very common in default stacks, at least it is on most that I personally deal with.

j2b’s picture

Great, thank you for reply. I noticed this dependency in Apache2 Error log, saying:

[Wed Nov 13 13:21:00 2013] [error] [client 192.169.123.7] PHP Fatal error: Call to undefined function curl_init() in /pat/to/drupal/public_html/sites/all/modules/contrib/btsync/btsync.class.inc on line 54, referer: http://test.example.com/node/add/bt-sync-folder-trigger

That's where I decided to add php5-curl, not just curl as OS application, and things started to work.

Regarding expectations of existing libraries in shared hosting solutions - yet this may differ very much. Especially, if we talk about more or less serious D sites, where in most cases regular shared hosting configurations might not be enough. That's my subjective feeling. But personally I do D on VPS type machines, thus giving freedom of libraries and configuration used.

I noticed this discussion in comments (if it may help or hint): https://api.drupal.org/api/drupal/includes!common.inc/function/drupal_ht... Where there is a notice of stream_socket_client() function limitations on some ISP side (in my case it may be not enabled at all), which, to my thinking, might lead to fact, that missing kind of regular stream options, as a fallback, http_get_request() might look for php5-curl. But I'd not claim myself as an expert in this. Just a thought, why still cURL was looked for.

Deciphered’s picture

Absolutely, the expectation of cURL being available is horribly wrong and purely accidental that I neither documented it or implemented it as a hook_requirement(). I intend to remedy that, hopefully by removing said dependency, before the next stable release.

I fully intend on doing some serious digging into why drupal_http_request() doesn't work in this instance ASAP, but in the small amount of time I have for contrib (outside of work hours) I've been working on my BTSync Fields module.

I get a lovely 3 hours of commute time tomorrow heading to and back from the monthly Drupal Mentoring session I run in Melbourne tomorrow, so I should get some time to look further into this issue then.

However, patches are always welcome. I'm also very interested in knowing what you are doing with the API or what you are planning.

Deciphered’s picture

Oh, and just re-reading your message, the last bit about why cURL is being used:

I specifically wrote a cURL handler instead of using drupal_http_request() as in my test before (and now) drupal_http_request() just times out when I try to use it with the API.

I'm trying to determine why drupal_http_request() times out when all other REST clients I've tested with work perfectly. If you're willing to do some test for me, I'd be happy to have the help.

Deciphered’s picture

So it looks like drupal_http_request() is never receiving an 'end of file' from the BTSync, so even though it's receiving the data it's staying connected until the connection times out and then it returns an error instead of the data.... I'm guessing this is an issue with the BTSync API http client, but I can't say for certain.

Trying to figure out a way to resolve the issue without having to rely on BTSync releasing a new version on me having to reinvent the wheel.

j2b’s picture

Thank you for detailed reports. As to my situation, I'm completely fine regarding cURL use and additional setup. Just wanted to find out, whether it was expected solution - which turns out 'yes' until now. If somebody would come up with the same issue, this ticket might indicate possible solution. Although, it might be helpful in module description page to post a NOTE: regarding this necessity, while it gets solved out.