title: TypeError: _this._transport.sendEvent is not a function
body: <p>I have successfully provisioned Device, I am using X509 certs for provisioning and its working fine. Now I want to send device messages to IoT hub, so I have created a separate class DeviceHelper, but I am getting this error. Can somebody please help?
  TypeError: _this._transport.sendEvent is not a function</p>
  
  <p>Code for Device Provisioning</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>var fs = require('fs');
  var DeviceHelper = require('./device-helper');
  var Transport = require('azure-iot-provisioning-device-http').Http;
  var X509Security = require('azure-iot-security-x509').X509Security;
  var ProvisioningDeviceClient = require('azure-iot-provisioning- 
  device').ProvisioningDeviceClient;
  // Register the device.  Do not force a re-registration.
          deviceClient.register(function (err, result) {
             if (err) {
                 that.setProvisionStatus(PROVISION_STATUS.ERROR);
              console.log(err);
          } else {
              console.log('registration succeeded');
              that.assignedHub = result.assignedHub;
              console.log('assigned hub=' + result.assignedHub);
              console.log('deviceId=' + result.deviceId);
              var deviceHelper = new DeviceHelper(that.deviceId, that.assignedHub, deviceCert, Transport);
              deviceHelper.sendEvent();
          }
      });</code></pre>
  </div>
  </div>
  </p>
  
  <p><strong>DeviceHelper code:</strong></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>   
  
   
  
  var Device = require('azure-iot-device');
      var Client = Device.Client;
      var X509AuthenticationProvider = Device.X509AuthenticationProvider;
      var Message = Device.Message;
      var Http = Device.Http;
  
      var client = {};
      class DeviceHelper {
  
        constructor(deviceId, hubName, security, transport) {
          client = Client.fromAuthenticationProvider(X509AuthenticationProvider.fromX509Options(
            deviceId, hubName, security
          ),transport);
        }
  
        print(err, res) {
          if (err) console.log(err.toString());
          if (res) console.log(res.statusCode + ' ' + res.statusMessage);
        }
  
        sendEvent() {
      // Error on this line
          client.sendEvent(new Message('hello world'), this.print);
        }
      }
  
      module.exports = DeviceHelper;</code></pre>
  </div>
  </div>
  </p>
  
  <p>Console log of the issue:</p>
  
  <pre><code>TypeError: _this._transport.sendEvent is not a function
  index.js:23
  message:"_this._transport.sendEvent is not a function"
  stack:"TypeError: _this._transport.sendEvent is not a function\n at D:\Working\Brahma\web-communicator\server\iot-agent\node_modules\azure-iot-device\lib\client.js:216:30\n at retryOperation (D:\Working\Brahma\web-communicator\server\iot-agent\node_modules\azure-iot-device\node_modules\azure-iot-common\lib\retry_operation.js:31:13)\n at RetryOperation.retry (D:\Working\Brahma\web-communicator\server\iot-agent\node_modules\azure-iot-device\node_modules\azure-iot-common\lib\retry_operation.js:57:9)\n at Client.sendEvent (server\iot-agent\node_modules\azure-iot-device\lib\client.js:214:17)\n at DeviceHelper.sendEvent (\device-helper.js:22:12)\n at \iot-device.js:99:30\n at D:\Working\Brahma\web-communicator\server\iot-agent\node_modules\azure-iot-provisioning-device\lib\x509_registration.js:50:33\n at constructor._onEnter (D:\Working\Brahma\web-communicator\server\iot...
  proto:Error {constructor: , name: "TypeError", message: "", …}
  </code></pre>