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

curl_easy_perform() failed: Out of memory error when uploading blobs #308

Closed
drhalftone opened this Issue Nov 20, 2017 · 46 comments

Comments

Projects
None yet
7 participants
@drhalftone

drhalftone commented Nov 20, 2017

Mac OS X 10.13.1
Mac Book Pro, mid-2014
Info: IoT Hub SDK for C, version 1.1.27

Description of the issue:

I'm trying to run the sample, iothub_client_sample_upload_to_blob.

Code sample exhibiting the issue:

iothub_client_sample_upload_to_blob.c

Console log of the issue:

Starting the IoTHub client sample upload to blob...
Info: IoT Hub SDK for C, version 1.1.27
Error: Time:Mon Nov 20 09:48:13 2017 File:/Users/dllau/azure-iot-sdk-c/c-utility/adapters/httpapi_curl.c Func:HTTPAPI_ExecuteRequest Line:556 curl_easy_perform() failed: Out of memory

Error: Time:Mon Nov 20 09:48:13 2017 File:/Users/dllau/azure-iot-sdk-c/c-utility/adapters/httpapi_curl.c Func:HTTPAPI_ExecuteRequest Line:558 (result = HTTPAPI_OPEN_REQUEST_FAILED)
Error: Time:Mon Nov 20 09:48:13 2017 File:/Users/dllau/azure-iot-sdk-c/c-utility/src/httpapiex.c Func:HTTPAPIEX_ExecuteRequest Line:475 unable to recover sending to a working state
Error: Time:Mon Nov 20 09:48:13 2017 File:/Users/dllau/azure-iot-sdk-c/iothub_client/src/iothub_client_ll_uploadtoblob.c Func:IoTHubClient_LL_UploadToBlob_step1and2 Line:396 unable to HTTPAPIEX_SAS_ExecuteRequest
Error: Time:Mon Nov 20 09:48:13 2017 File:/Users/dllau/azure-iot-sdk-c/iothub_client/src/iothub_client_ll_uploadtoblob.c Func:IoTHubClient_LL_UploadToBlob_Impl Line:873 error in IoTHubClient_LL_UploadToBlob_step1
hello world failed to upload

@drhalftone

This comment has been minimized.

drhalftone commented Nov 20, 2017

This may be covered by a previous issue; however, that previous issue was for a different code sample and different OS.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Nov 22, 2017

Hi @drhalftone ,
does the issue occur right away when the sample is run?
Could you run a little experiment on your machine please? Could you run this sample as well?

Also it is going to be much easier to debug if we have verbose logging enabled.
On each sample, after "IoTHubClient_LL_CreateFromConnectionString" could you add this line please?

size_t log = 1;
(void)IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_CURL_VERBOSE, &log);

Make sure you have this include definition on the top of each sample:

#include "azure_c_shared_utility/shared_util_options.h"

@ewertons ewertons self-assigned this Nov 22, 2017

@drhalftone

This comment has been minimized.

drhalftone commented Nov 26, 2017

@jongio

This comment has been minimized.

Contributor

jongio commented Dec 4, 2017

This is a valid workaround that will remove openssl in favor of gnutls.

cd build_all/linux

./setup.sh

sudo apt remove libcurl4-openssl-dev
sudo apt install libcurl4-gnutls-dev

./build.sh
@drhalftone

This comment has been minimized.

drhalftone commented Dec 10, 2017

Is there any progress on this for Mac OS X?

@jongio

This comment has been minimized.

Contributor

jongio commented Dec 12, 2017

@drhalftone, @tameraw @jebrando are working on a permanent fix. ETA this month. I've asked them to ensure they test on Mac as well.

@drhalftone

This comment has been minimized.

drhalftone commented Dec 18, 2017

That would be awesome!

@jongio

This comment has been minimized.

Contributor

jongio commented Dec 20, 2017

@drhalftone - I researched a workaround with Mac, but I wasn't able to find one. The fix should be rolled out soon. @zolvarga @jebrando

@jebrando jebrando self-assigned this Jan 11, 2018

@jebrando

This comment has been minimized.

Collaborator

jebrando commented Jan 11, 2018

@drhalftone for data sake are you working in the c-sdk or python-sdk? Also how many devices are being returned in your query. This bug has been very elusive, but I think I'm on to something.

@drhalftone

This comment has been minimized.

drhalftone commented Jan 11, 2018

@jongio

This comment has been minimized.

Contributor

jongio commented Jan 11, 2018

@jebrando - He is getting this error when trying to upload to blob. Get devices is also an issue, but any call that uses the curl lib has this error.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Jan 11, 2018

Hi @drhalftone,
upon investigating it seems that the failure is related to bugs in the curl library related to redirection between HTTP and HTTPS.
There is a thread discussing the topic.
Previous versions of curl had an option to initialize support for SSL (as shown here: https://curl.haxx.se/libcurl/c/curl_global_init.html, "CURL_GLOBAL_SSL"), however when we tried setting it we incurred in a segmentation fault:

Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Starting the IoTHub client sample upload to blob...
[New Thread 0x7ffff208f700 (LWP 16387)]
[Thread 0x7ffff208f700 (LWP 16387) exited]
*   Trying 111.22.33.444...
* TCP_NODELAY set
* Connected to some-iot-hub.azure-devices.net (111.22.33.444) port 443 (#0)
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: /etc/ssl/certs

Thread 1 "iothub_client_s" received signal SIGSEGV, Segmentation fault.
__GI___pthread_rwlock_wrlock (rwlock=0x0) at pthread_rwlock_wrlock.c:100
100     pthread_rwlock_wrlock.c: No such file or directory.

So the last resort was trying to upgrade curl to the latest version available, and that actually resulted in no errors.

ewertons@ewertons-debian921:~$ dpkg -l | grep -i curl
ii  curl                          7.57.0-1                       amd64        Curl 7.57
ii  libcurl3:amd64                7.57.0-1                       amd64        easy-to-use client-side URL transfer library (OpenSSL flavour)
ri  libcurl3-gnutls:amd64         7.52.1-5+deb9u3                amd64        easy-to-use client-side URL transfer library (GnuTLS flavour)
iU  libcurl4-openssl-dev:amd64    7.57.0-1                       amd64        development files and documentation for libcurl (OpenSSL flavour)
ri  python3-pycurl                7.43.0-2                       amd64        Python bindings to libcurl (Python 3)
ewertons@ewertons-debian921:~$
ewertons@ewertons-debian921:~/azure-iot-sdk-c/cmake/iothub_client/samples/iothub_client_sample_upload_to_blob$ ./iothub_client_sample_upload_to_blob
./iothub_client_sample_upload_to_blob: /usr/local/lib/libcurl.so.4: no version information available (required by ./iothub_client_sample_upload_to_blob)
Starting the IoTHub client sample upload to blob...
*   Trying 111.22.33.444...
* TCP_NODELAY set
* Connected to some-iot-hub.azure-devices.net (111.22.33.444) port 443 (#0)
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*   CAfile: /etc/ssl/certs/ca-certificates.crt
  CApath: none
* SSL connection using TLSv1.2 / ECDHE-RSA-AES128-SHA256
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: CN=*.azure-devices.net
*  start date: May 12 01:25:52 2017 GMT
*  expire date: May  7 17:03:30 2018 GMT
*  subjectAltName: host "some-iot-hub.azure-devices.net" matched cert's "*.azure-devices.net"
*  issuer: C=US; ST=Washington; L=Redmond; O=Microsoft Corporation; OU=Microsoft IT; CN=Microsoft IT SSL SHA2
*  SSL certificate verify ok.
> POST /devices/some-device-id/files?api-version=2016-11-14 HTTP/1.1
...
* upload completely sent off: 66 out of 66 bytes
< HTTP/1.1 204 No Content
< Content-Length: 0
< Server: Microsoft-HTTPAPI/2.0
< Date: Thu, 11 Jan 2018 22:14:28 GMT
<
* Connection #0 to host some-iot-hub.azure-devices.net left intact
hello world has been created
@ewertons

This comment has been minimized.

Collaborator

ewertons commented Jan 11, 2018

So the recommended solution for this issue is upgrading curl to the latest version available (as of today, 7.57).

Would it be possible for you to upgrade your version of curl and confirm the upload to blob feature works for you?

@drhalftone

This comment has been minimized.

drhalftone commented Jan 12, 2018

So i'm not sure exactly what I'm supposed to do. I assume you want me to install curl through brew. I also think you want me to use the --with-openssl option. So I did use brew; however, brew says that the curl installation is keg only. I also see some instructions about how to get a project to link to this brew version of curl, superseding the Mac OS X version.

Should I follow those instructions and link to the brew version of curl?

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Jan 12, 2018

Hi @drhalftone ,
yes, the solution is to upgrade the curl libraries in your system to the latest version.
The details of upgrading a specific package on the Mac OS usually are made available by the provider of the platform.

And correct, you should use --with-openssl if building the SDK on a platform that doesn't have OpenSSL as its default library for SSL encryption.

@drhalftone

This comment has been minimized.

drhalftone commented Jan 12, 2018

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Jan 16, 2018

Hi @drhalftone ,
different than OpenSSL, the Azure IoT C SDK does not link against curl libraries using custom paths.
It uses the standard library paths in the system to search for the package.
Would it be possible for you to upgrade the curl libraries in directly in your system?

@drhalftone

This comment has been minimized.

drhalftone commented Jan 16, 2018

How do I do that? I can only do what brew tells me, and here is what it says when I try to install curl:

DrHalftone:~ dllau$ brew install curl
==> Downloading https://homebrew.bintray.com/bottles/curl-7.57.0.high_sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring curl-7.57.0.high_sierra.bottle.tar.gz
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.

If you need to have this software first in your PATH run:
echo 'export PATH="/usr/local/opt/curl/bin:$PATH"' >> ~/.bash_profile

For compilers to find this software you may need to set:
LDFLAGS: -L/usr/local/opt/curl/lib
CPPFLAGS: -I/usr/local/opt/curl/include
For pkg-config to find this software you may need to set:
PKG_CONFIG_PATH: /usr/local/opt/curl/lib/pkgconfig

==> Summary

@drhalftone

This comment has been minimized.

drhalftone commented Jan 20, 2018

It's working! Okay, I did have to link against the brew version of curl by setting the following flags in the CMake GUI utility:

LDFLAGS: -L/usr/local/opt/curl/lib
CPPFLAGS: -I/usr/local/opt/curl/include

I then had the certificates issue. So I was in the process of setting the verbose flag to 1, but that option fails in the upload_blob sample. But at the same time, even though I didn't successfully set the verbose flag, the code is reporting that it is now working:

DrHalftone:iothub_client_sample_upload_to_blob dllau$ ./iothub_client_sample_upload_to_blob
Starting the IoTHub client sample upload to blob...
Error: Time:Fri Jan 19 20:01:06 2018 File:/Users/dllau/azure-iot-sdk-c/iothub_client/src/iothub_client_ll.c Func:IoTHubClient_LL_SetOption Line:1704 invalid argument (NULL)
Info: IoT Hub SDK for C, version 1.1.29
Error: Time:Fri Jan 19 20:01:06 2018 File:/Users/dllau/azure-iot-sdk-c/c-utility/adapters/httpapi_curl.c Func:HTTPAPI_SetOption Line:800 failure in curl_easy_setopt - CURLOPT_SSL_CTX_FUNCTION
Error: Time:Fri Jan 19 20:01:06 2018 File:/Users/dllau/azure-iot-sdk-c/c-utility/src/httpapiex.c Func:HTTPAPIEX_ExecuteRequest Line:400 HTTPAPI_SetOption failed when called for option TrustedCerts
Error: Time:Fri Jan 19 20:01:06 2018 File:/Users/dllau/azure-iot-sdk-c/c-utility/adapters/httpapi_curl.c Func:HTTPAPI_SetOption Line:800 failure in curl_easy_setopt - CURLOPT_SSL_CTX_FUNCTION
Error: Time:Fri Jan 19 20:01:06 2018 File:/Users/dllau/azure-iot-sdk-c/c-utility/src/httpapiex.c Func:HTTPAPIEX_ExecuteRequest Line:400 HTTPAPI_SetOption failed when called for option TrustedCerts
hello world has been created

At the moment, I don't know exactly what combination of things I've tried did the trick or if I am going to be able to repeat the process. But at least I know some combination fixed it.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Jan 22, 2018

Indeed.
To give a step further and help increase the confidence on your setup, I would suggest you use Storage Explorer to verify your file got created.

[details to come in a moment]

Thanks for pushing through, I believe your system is good to go, we just want to be sure.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Jan 29, 2018

Hi @drhalftone ,
that indeed should be reflected in the documentation.
A PR has been posted here, could you take a look and review it as well please?
#367

Feel free to leave any comments regarding the content or language.

Thanks,
Azure IoT Team

@jspaith jspaith removed the enhancement label Jan 29, 2018

@tjhgit

This comment has been minimized.

tjhgit commented Feb 6, 2018

It was very unclear to me how @drhalftone did achieve to include the brew installed curl in the compile.

So it is a simple as adding to the cmake command in azure-iot-sdk-python/build_all/mac/build.sh these additional arguments: -DCURL_INCLUDE_DIR:PATH=/usr/local/opt/curl/include -DCURL_LIBRARY:FILEPATH=/usr/local/opt/curl/lib/libcurl.4.dylib.

I can confirm that then the HTTP_API error is solved on mac.

You can find out about these two compile arguments by starting the cmake-gui and choosing as BUILD_DIR = azure-iot-sdk-python/c/cmake/iotsdk_mac. And the press the advanced flag option, to see all advanced flags.

@drhalftone

This comment has been minimized.

drhalftone commented Feb 14, 2018

First, I just cloned a clean and new copy of the azure iot GitHub account, but there is no "Mac" directory inside the build_all directory. Here is what is in the build_all directory:

drwxr-xr-x 11 dllau staff 352 Feb 14 13:01 .
drwxr-xr-x 32 dllau staff 1024 Feb 14 13:04 ..
drwxr-xr-x 7 dllau staff 224 Feb 14 13:01 arduino
drwxr-xr-x 3 dllau staff 96 Feb 14 13:01 docs
drwxr-xr-x 6 dllau staff 192 Feb 14 13:01 linux
drwxr-xr-x 3 dllau staff 96 Feb 14 13:01 mbed
drwxr-xr-x 4 dllau staff 128 Feb 14 13:01 packaging
drwxr-xr-x 5 dllau staff 160 Feb 14 13:01 tirtos
drwxr-xr-x 4 dllau staff 128 Feb 14 13:01 tizenRT
drwxr-xr-x 5 dllau staff 160 Feb 14 13:01 windows
drwxr-xr-x 3 dllau staff 96 Feb 14 13:01 windowsce

So I tried running cmake according to:

cmake -DOPENSSL_ROOT_DIR:PATH=/usr/local/opt/openssl -DCURL_INCLUDE_DIR:PATH=/usr/local/opt/curl/include -DCURL_LIBRARY:FILEPATH=/usr/local/opt/curl/lib/libcurl.4.dylib ..

and got the following response:

CMake Warning:
Manually-specified variables were not used by the project:

CURL_INCLUDE_DIR
CURL_LIBRARY

Can you please post detailed instructions on how you confirmed that the errors went away on Mac? Since I am now using curl 7.58.0, I can say that it is no longer working. And I haven't been able to re-compile my code successfully. So I am back of the opinion that Azure IOT does not run on Mac.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Feb 17, 2018

Ok, let's sort things out.
@tjhgit mentioned "azure-iot-sdk-python/build_all/mac/build.sh" on the previous post. That's the python SDK repo, different of this C SDK repo, so the path is not applicable. That's why you didn't find the path, @drhalftone .

As per the exact command line options, we will post the syntax here and in the documentation soon.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Feb 17, 2018

@drhalftone,
could you please verify if you get the sample working successfully with these instructions?

  1. Install the latest version of curl
    macosx:~ username$ brew install curl
    (I believe you already did this part.)

At the end of the installation you will get this info:

Error: Failed to create /usr/local/opt/curl
...
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
...
==> Summary
🍺  /usr/local/Cellar/curl/7.58.0: 415 files, 3MB

Save the path "/usr/local/Cellar/curl/7.58.0", this is where the library and headers were actually installed.

  1. Clone the azure-iot-sdk-c
    Steps below will assume the SDK is at ~/azure-iot-sdk-c

Do not forget to modify the file bellow to include your device connection string:
~/azure-iot-sdk-c/iothub_client/samples/iothub_client_sample_upload_to_blob/iothub_client_sample_upload_to_blob.c

  1. Create the make files using cmake, passing also the custom paths to libraries to be used:
macosx:cmake username$ cmake -DOPENSSL_ROOT_DIR:PATH=/usr/local/opt/openssl -DCURL_INCLUDE_DIR:PATH=/usr/local/Cellar/curl/7.58.0/include -DCURL_LIBRARY:FILEPATH=/usr/local/Cellar/curl/7.58.0/lib/libcurl.dylib ~/azure-iot-sdk-c
  1. Build the solution:
    macosx:iothub_client_sample_upload_to_blob username$ make -j `nproc`

  2. Set DYLD_LIBRARY_PATH:
    export DYLD_LIBRARY_PATH=/usr/local/Cellar/curl/7.58.0/lib

NOTE: BE CAREFUL NOT TO OVERRIDE THE VARIABLE IF YOU ALREADY HAVE IT SET ON YOUR SYSTEM.

  1. Run the sample:
macosx:iothub_client_sample_upload_to_blob username$ ./iothub_client_sample_upload_to_blob
...
* upload completely sent off: 66 out of 66 bytes
< HTTP/1.1 204 No Content
< Content-Length: 0
< Server: Microsoft-HTTPAPI/2.0
< Date: Sat, 17 Feb 2018 01:09:32 GMT
<
* Connection #0 to host someiothub.azure-devices.net left intact
hello world has been created
macosx:iothub_client_sample_upload_to_blob username$
@drhalftone

This comment has been minimized.

drhalftone commented Feb 17, 2018

Here is the result of the cmake command. Note I was inside, "/Users/dllau/azure-iot-sdk-c/cmake"

DrHalftone:cmake dllau$ cmake -DOPENSSL_ROOT_DIR:PATH=/usr/local/opt/openssl -DCURL_INCLUDE_DIR:PATH=/usr/local/Cellar/curl/7.58.0/include -DCURL_LIBRARY:FILEPATH=/usr/local/Cellar/curl/7.58.0/lib/libcurl.dylib ~/azure-iot-sdk-c
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- IoT Client SDK Version = 1.1.31
-- Looking for include file stdint.h
-- Looking for include file stdint.h - found
-- Looking for include file stdbool.h
-- Looking for include file stdbool.h - found
-- target architecture: x86_64
-- Performing Test CXX_FLAG_CXX11
-- Performing Test CXX_FLAG_CXX11 - Success
-- Found OpenSSL: /usr/local/opt/openssl/lib/libcrypto.dylib (found version "1.0.2n")
-- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.29.2")
-- Checking for module 'libcurl'
-- Found libcurl, version 7.54.0
-- Found CURL: curl
-- target architecture: x86_64
-- target architecture: x86_64
-- target architecture: x86_64
-- target architecture: x86_64
-- iothub architecture: x86_64
-- Configuring done
-- Generating done
CMake Warning:
Manually-specified variables were not used by the project:

CURL_INCLUDE_DIR
CURL_LIBRARY

-- Build files have been written to: /Users/dllau/azure-iot-sdk-c/cmake
DrHalftone:cmake dllau$

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Feb 17, 2018

Could you confirm:

  1. If /usr/local/Cellar/curl/7.58.0 exists in your machine
  2. your version of cmake
@drhalftone

This comment has been minimized.

drhalftone commented Feb 17, 2018

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Feb 17, 2018

This could be a cmake version issue. We have cmake version 3.7
https://cmake.org/cmake/help/v3.10/command/find_package.html?highlight=find_package

Could you add these two options to your cmake command line and try again?
-DNO_CMAKE_PATH=TRUE -DCURL_DIR:PATH=/usr/local/Cellar/curl/7.58.0

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Feb 17, 2018

Thanks for helping running the verifications, as you know Mac OS is quite strict when it comes to updates, so changing the version of cmake in our environment is not so straightforward.

@drhalftone

This comment has been minimized.

drhalftone commented Feb 17, 2018

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Feb 21, 2018

@drhalftone,
at this point we will need to have a environment that fully match yours to attempt a repro and get instructions to suffice for you to successfully build and run the azure-iot-sdk-c samples.
We will get a new MacOSX machine available within the next days, and we then will proceed with this investigation.
If we cannot get a repro, we will contact you for perhaps a live session so we can work directly on your environment, if possible.

@drhalftone

This comment has been minimized.

drhalftone commented Feb 21, 2018

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Mar 5, 2018

Starting on OS X El Capitan, Mac OS comes with SIP (System Integrity Protection) which blocks brew from installing/creating links over the existing paths on /usr/* (https://support.apple.com/en-us/HT204899)
After installing curl with brew and forcing link creations (into /usr/local/*), cmake is able to recognize the keg version of curl installed.
However since the original curl libraries are not overwritten (under /usr/lib), the application will still find the old libcurl.4.dylib (on High Sierra, 7.54.0) and use it, reproducing the bug described in this issue.
To complete the workaround one must set DYLD_LIBRARY_PATH.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Mar 5, 2018

Could you try these updated steps please?

  1. Install the latest version of curl
    macosx:~ username$ brew install curl

At the end of the installation you will get this info:

Error: Failed to create /usr/local/opt/curl
...
==> Caveats
This formula is keg-only, which means it was not symlinked into /usr/local,
because macOS already provides this software and installing another version in
parallel can cause all kinds of trouble.
...
==> Summary
🍺  /usr/local/Cellar/curl/7.58.0: 415 files, 3MB

Save the path "/usr/local/Cellar/curl/7.58.0", this is where the library and headers were actually installed.

  1. Force link updates:
brew link curl --force
  1. Set DYLD_LIBRARY_PATH:
export DYLD_LIBRARY_PATH="/usr/local/Cellar/curl/7.58.0/lib:$DYLD_LIBRARY_PATH"
  1. Clone the azure-iot-sdk-c
    Steps below will assume the SDK is at ~/azure-iot-sdk-c

Do not forget to modify the file bellow to include your device connection string:
~/azure-iot-sdk-c/iothub_client/samples/iothub_client_sample_upload_to_blob/iothub_client_sample_upload_to_blob.c

  1. Create the make files using cmake, passing also the custom paths to libraries to be used:
macosx:cmake username$ cmake ~/azure-iot-sdk-c
  1. Build the solution:
    macosx:iothub_client_sample_upload_to_blob username$ make -j `nproc`

  2. Run the sample:

macosx:iothub_client_sample_upload_to_blob azureiotcl$ ./iothub_client_sample_upload_to_blob 
...
@tameraw

This comment has been minimized.

Contributor

tameraw commented Mar 5, 2018

@drhalftone - please confirm if the instructions above from @ewertons resolve your issue and if you have any additional feedback. Thanks.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Mar 12, 2018

Hi @drhalftone,
we will close this issue but feel free to reopen it once you have chance to follow up on the last details.
Thanks,
Azure IoT Team.

@ewertons ewertons closed this Mar 12, 2018

@drhalftone

This comment has been minimized.

drhalftone commented Mar 13, 2018

It seems to be working. The file is created in my azure storage account; however, I do see these two lines on the output:

Starting the IoTHub client sample upload to blob...
Error: Time:Mon Mar 12 23:11:05 2018 File:/Users/dllau/azure-iot-sdk-c/c-utility/adapters/httpapi_curl.c Func:HTTPAPI_SetOption Line:831 failure in curl_easy_setopt - CURLOPT_SSL_CTX_FUNCTION
Error: Time:Mon Mar 12 23:11:05 2018 File:/Users/dllau/azure-iot-sdk-c/c-utility/src/httpapiex.c Func:HTTPAPIEX_ExecuteRequest Line:400 HTTPAPI_SetOption failed when called for option TrustedCerts

Is this a concern?

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Mar 13, 2018

Is it working?

@drhalftone

This comment has been minimized.

drhalftone commented Mar 13, 2018

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Mar 13, 2018

Then no, it's not a concern.

@drhalftone

This comment has been minimized.

drhalftone commented Mar 13, 2018

Then I am happy to say that it works. I think you should point out that the magic sauce is the line:

export DYLD_LIBRARY_PATH="/usr/local/Cellar/curl/7.58.0/lib:$DYLD_LIBRARY_PATH"

This has to be run anytime I want to run the compiled executable not when I want to compile. So this is the line that tells the executable which curl library to use. It is not needed to be run before compiling.

@ewertons

This comment has been minimized.

Collaborator

ewertons commented Mar 13, 2018

Alright, glad to hear that.
Although the whole steps needed to upgrade curl (on any dependency) on a specific OS is not part of the core instruction set we manage within our solution, we will save that (with the rest of the steps above) in our documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment