I'm testing a deployment of the Eclipse IoT Cloud2Edge package and have followed the instructions here https://www.eclipse.org/packages/packages/cloud2edge/tour/ to test. After creating the new tenant and device, and configuring the connection between Hono and Ditto, I can send telemetry to the new device via the Hono http adapter as shown here:
curl -i -u my-auth-id-1#my-tenant:my-password -H 'application/json' --data-binary '{
"topic": "my-tenant/org.acme:my-device-1/things/twin/commands/modify",
"headers": {},
"path": "/features/temperature/properties/value",
"value": 53
}' http://${HTTP_ADAPTER_IP}:${HTTP_ADAPTER_PORT_HTTP}/telemetry
HTTP/1.1 202 Accepted
vary: origin
content-length: 0
and expected to see this property value updated in Ditto. The updated device property value does not update in Ditto, and when I check the Ditto logs I see the following entries:
2022-02-13 20:11:35,265 INFO [] o.e.d.c.s.m.a.AmqpConsumerActor akka://ditto-cluster/system/sharding/connection/3/hono-connection-for-my-tenant/pa/$a/c1/amqpConsumerActor-0-telemetry%2Fmy-tenant-010 - Received message from AMQP 1.0 with externalMessageHeaders: {orig_adapter=hono-http, qos=0, device_id=org.acme:my-device-1, creation-time=1644783095260, message-id=ID:AMQP_NO_PREFIX:GenericSenderLink-12, content-type=application/x-www-form-urlencoded, to=telemetry/my-tenant, orig_address=/telemetry}
2022-02-13 20:11:35,271 INFO [81c41f10-4d59-435b-8ae1-bf5194dcf6bf] o.e.d.c.s.m.InboundDispatchingSink - onMapped mappedHeaders ImmutableDittoHeaders [{ditto-entity-id=thing:my-tenant:org.acme:my-device-1, ditto-inbound-payload-mapper=default, content-type=application/x-www-form-urlencoded, hono-device-id=org.acme:my-device-1, ditto-reply-target=0, ditto-expected-response-types=["response","error"], ditto-origin=hono-connection-for-my-tenant, ditto-auth-context={"type":"pre-authenticated-connection","subjects":["pre-authenticated:hono-connection"]}, correlation-id=81c41f10-4d59-435b-8ae1-bf5194dcf6bf}]
2022-02-13 20:11:35,278 INFO [b3b11410-6df8-4bfc-a940-fafa87d65be2] o.e.d.c.s.m.InboundDispatchingSink - Got exception <connectivity:connection.id.enforcement.failed> when processing external message with mapper <default>: <The configured filters could not be matched against the given target with ID 'org.acme:my-device-1'.>
2022-02-13 20:11:35,278 INFO [b3b11410-6df8-4bfc-a940-fafa87d65be2] o.e.d.c.s.m.InboundDispatchingSink - Resolved mapped headers of ImmutableDittoHeaders [{ditto-inbound-payload-mapper=default, ditto-entity-id=thing:my-tenant:org.acme:my-device-1, response-required=false, content-type=application/x-www-form-urlencoded, hono-device-id=org.acme:my-device-1, ditto-reply-target=0, ditto-expected-response-types=["response","error"], ditto-origin=hono-connection-for-my-tenant, ditto-auth-context={"type":"pre-authenticated-connection","subjects":["pre-authenticated:hono-connection"]}, correlation-id=b3b11410-6df8-4bfc-a940-fafa87d65be2}] : with HeaderMapping Optional[ImmutableHeaderMapping [mapping={hono-device-id={{ header:device_id }}, content-type={{ header:content-type }}}]] : and external headers {orig_adapter=hono-http, qos=0, device_id=org.acme:my-device-1, creation-time=1644783095260, message-id=ID:AMQP_NO_PREFIX:GenericSenderLink-12, content-type=application/x-www-form-urlencoded, to=telemetry/my-tenant, orig_address=/telemetry}
2022-02-13 20:11:35,283 INFO [] o.e.d.c.s.m.a.AmqpConsumerActor akka://ditto-cluster/system/sharding/connection/3/hono-connection-for-my-tenant/pa/$a/c1/amqpConsumerActor-0-telemetry%2Fmy-tenant-010 - Acking <ID:AMQP_NO_PREFIX:GenericSenderLink-12> with original external message headers=<{orig_adapter=hono-http, qos=0, device_id=org.acme:my-device-1, creation-time=1644783095260, message-id=ID:AMQP_NO_PREFIX:GenericSenderLink-12, content-type=application/x-www-form-urlencoded, to=telemetry/my-tenant, orig_address=/telemetry}>, isSuccess=<true>, ackType=<1 accepted>
I think the problem is the "connectivity:connection.id.enforcement.failed" error but I don't know how to troubleshoot. Any advice appreciated.
What you configured is the Connection source enforcement which makes sure that a Hono device (identified via the AMQP header device_id) may only updates the twin with the same "thing id" in Ditto.
That enforcement fails as your thingId you set in the Ditto Protocol JSON is my-tenant:org.acme:my-device-1 - the topic's first segment is the namespace, the second segment the name - combined those 2 segments become the "thing ID", see also: Protocol topic specification.
So you probably want to send the following message instead:
{
"topic": "org.acme/my-device-1/things/twin/commands/modify",
...
}
Related
I want to learn how to use logstash with mailtrap smtp for development purposes. I installed logstash then ran this command:
/usr/share/logstash/bin/logstash -e 'input { stdin { } } output { email {
to => "user#example.com"
from => "user#example.com"
subject => "Alert - %{title}"
body => "content here"
authentication => "plain"
domain => "smtp.mailtrap.io:2525"
username => "20ff3475e0c350"
password => "594980b5a1be46"
}
}'
Once logstash is up and running, I type something and press enter. This causes the error below:
[ERROR] 2022-11-08 19:34:59.861 [[main]>worker1] email - Something happen while delivering an email {:exception=>#<Net::SMTPAuthenticationError: 503 5.5.1 Error: authentication not enabled
How do I enable authentication? Or what am I doing wrong? I also can't find any documentation on what are acceptable values for the authentication property.
I've been using Kaleido's FabConnect API to invoke some transactions from a sample fabric smart contract using this request:
curl -X 'POST'
'https://u0jzrmv8ok-u0nh6n12o1-connect.us0-aws-ws.kaleido.io/transactions?fly-sync=true'
-H 'accept: /'
-H 'Content-Type: application/json'
-d '{
"headers": {
"type": "SendTransaction",
"signer": "user2",
"channel": "ustrades",
"chaincode": "asset_transfer"
},
"func": "GetAllAssets",
"args": [
"string"
],
"init": false
}'
but I get the following error: {
"error": "Failed to submit: error getting channel response for channel [ustrades]: Discovery status Code: (11) UNKNOWN. Description: error received from Discovery Server: failed constructing descriptor for chaincodes:<name:"asset_transfer" > "
}
I've seen a similar problem where the solution offered was to add anchor peer nodes, but how exactly do you do that on Kaleido. Their customer support is slow getting back to me, so I thought I'd ask here.
I am currently using SDK version 3.39.0 and version 0004 of the API_MKT_CONTACT service definition to create a new Contact in Marketing Cloud with the following code:
ContactOriginData contact =
ContactOriginData.builder()
.originOfContact(origin)
.originTimestamp(ZonedDateTime.now())
.externalContactID(pii.getId().toString())
.firstName(pii.getFirstName())
.lastName(pii.getLastName())
.language(pii.getLanguage())
.countryReg(pii.getRegion())
.build();
// use low level API as a work around for https://github.com/SAP/cloud-sdk/issues/156
ODataRequestUpdate contactRequest = service
.updateContactOriginData(contact)
.withHeader("Sap-Cuan-RequestTimestamp", getFormattedTime(System.currentTimeMillis()))
.withHeader("Sap-Cuan-SequenceId", "UpdatePatch")
.withHeader("Sap-Cuan-SourceSystemType", "EXT")
.withHeader("Sap-Cuan-SourceSystemId", "sdk-test")
.toRequest();
String servicePath = "/sap/opu/odata/SAP/API_MKT_CONTACT_SRV;v=0004";
ODataRequestBatch requestBatch = new ODataRequestBatch(servicePath, ODataProtocol.V2);
requestBatch.beginChangeset().addUpdate(contactRequest).endChangeset();
HttpClient httpClient = HttpClientAccessor.getHttpClient(destination);
ODataRequestResultMultipartGeneric batchResult = requestBatch.execute(httpClient);
Running this produces the following error:
{
"error": {
"code": "/IWFND/CM_MGW/096",
"message": {
"lang": "en",
"value": "PATCH requests require components to be updated"
},
"innererror": {
"application": {
"component_id": "CEC-MKT-DM-IC",
"service_namespace": "/SAP/",
"service_id": "API_MKT_CONTACT_SRV",
"service_version": "0004"
},
"transactionid": "3B63A2A6CC920630E0060492A51E7EE7",
"timestamp": "20210310210334.4378960",
"Error_Resolution": {
"SAP_Transaction": "For backend administrators: use ADT feed reader \"SAP Gateway Error Log\" or run transaction /IWFND/ERROR_LOG on SAP Gateway hub system and search for entries with the timestamp above for more details",
"SAP_Note": "See SAP Note 1797736 for error analysis (https://service.sap.com/sap/support/notes/1797736)",
"Batch_SAP_Note": "See SAP Note 1869434 for details about working with $batch (https://service.sap.com/sap/support/notes/1869434)"
},
"errordetails": []
}
}
}
However, if I execute a similar request in postman it works without issue:
Request Payload:
--batch
Content-Type: multipart/mixed; boundary=changeset
--changeset
Content-Type: application/http
Content-Transfer-Encoding: binary
PATCH ContactOriginData(ContactOrigin='<ContactOrigin>',ContactID='24D8F7F6-440D-44F8-A24B-552435477688') HTTP/1.1
Accept: application/json
Content-Type: application/json
Content-Length: 172
Sap-Cuan-RequestTimestamp: '2021-03-10T14:07:00.000'
Sap-Cuan-SequenceId: UpdatePatch
Sap-Cuan-SourceSystemType: EXT
Sap-Cuan-SourceSystemId: postman-test
{"OriginDataLastChgUTCDateTime":"/Date(1615410479885)/","EmailAddress":"samantha.cook#theoasis.com","FirstName":"Samantha","LastName":"Cook","Country":"US","Language":"EN"}
--changeset--
--batch--
Response Payload:
--1D7E85E6BC66B34E61ACF0EF3964CBD90
Content-Type: multipart/mixed; boundary=1D7E85E6BC66B34E61ACF0EF3964CBD91
Content-Length: 430
--1D7E85E6BC66B34E61ACF0EF3964CBD91
Content-Type: application/http
Content-Length: 262
content-transfer-encoding: binary
HTTP/1.1 204 No Content
Content-Length: 0
dataserviceversion: 2.0
sap-message: {"code":"HPA_STAGING_AREA/037","message":"Payload is processed via staging area. See Import Monitor for details.","target":"","severity":"info","transition":false,"details":[]}
--1D7E85E6BC66B34E61ACF0EF3964CBD91--
--1D7E85E6BC66B34E61ACF0EF3964CBD90--
I should note that I have also tried using .replacingEntity() which doesn't work either and produces a completely different error:
Inline component is not defined or not allowed (HTTP PUT)
Is there something with the SDK that I am missing or not using correctly?
Any help would be appreciated!
Cheers!
To update an entity you should get it from the service first. That is regardless whether you are using:
PATCH which will update only changed fields
or PUT which will send the full entity object
Currently you are creating a new entity object via the builder: ContactOriginData.builder(). Instead, please use the corresponding getContactOriginDataByKey() method of your service to first retrieve the entity to update from the service. Actually many services will force you to do this to ensure you are always editing the latest version of your data. This often happens via ETags which the SDK will also handle for you automatically.
You can find more information about the update strategies from the SDK on the documentaiton.
Edit:
As you pointed out in the comments the actual goal is to create an entity and the specific service in question only allows PUT and PATCH to create objects.
In that case using replacingEntity() (which translates to PUT) should already work with your code. You can make PATCH work as well by replacing the builder approach with a constructor call + setter approach.
I've enabled diagnostic logs for APIM which are being sent to log-analytics.
Scenario
All incoming requests to server have RequestTracking_Id header.
All backend services use RequestTracking_Id header from the request in logs to track the request.
But from in APIM logs, I'm not able to pull this header to query upon.
Is there any way it is possible to have header information of incoming requests in APIM diagnostic logs?
Query:
AzureDiagnostics
| where Type contains "Azure" and Resource contains "APIM-DEV" and backendUrl_s contains "/relativePath" and DurationMs > 2000
The columns which are available on querying are :
TenantId SourceSystem MG ManagementGroupName TimeGenerated Computer activityId_g requestResourceType_s requestResourceId_s collectionRid_s statusCode_s duration_s clientIpAddress_s requestCharge_s requestLength_s responseLength_s resourceTokenUserRid_s region_s partitionId_g error_number_d Severity user_defined_b state_d exec_type_d wait_category_s total_query_wait_time_ms_d max_query_wait_time_ms_d is_parameterizable_s statement_type_s statement_key_hash_s query_param_type_d interval_start_time_d interval_end_time_d logical_io_writes_d max_logical_io_writes_d physical_io_reads_d max_physical_io_reads_d logical_io_reads_d max_logical_io_reads_d execution_type_d count_executions_d cpu_time_d max_cpu_time_d dop_d max_dop_d rowcount_d max_rowcount_d query_max_used_memory_d max_query_max_used_memory_d duration_d max_duration_d num_physical_io_reads_d max_num_physical_io_reads_d log_bytes_used_d max_log_bytes_used_d query_id_d query_hash_s plan_id_d query_plan_hash_s statement_sql_handle_s LogicalServerName_s ElasticPoolName_s DatabaseName_s start_utc_date_t end_utc_date_t wait_type_s delta_max_wait_time_ms_d delta_signal_wait_time_ms_d delta_wait_time_ms_d delta_waiting_tasks_count_d keyProperties_curve_s keyProperties_operations_s keyProperties_attributes_enabled_b algorithm_s identity_claim_xms_mirid_s lastError_transportErrorCode_d subnetId_s backendMethod_s backendUrl_s backendResponseCode_d backendTime_d requestSize_d productId_s userId_s apimSubscriptionId_s backendProtocol_s secretProperties_attributes_enabled_b clientIp_s clientPort_s ruleSetType_s ruleSetVersion_s ruleId_s Message action_s site_s details_message_s details_data_s details_file_s details_line_s hostname_s apiId_s operationId_s apiRevision_s clientIP_s clientPort_d httpMethod_s requestQuery_s userAgent_s httpStatus_d httpVersion_s receivedBytes_d sentBytes_d timeTaken_d sslEnabled_s host_s Level_d isRequestSuccess_b location_s lastError_source_s lastError_reason_s lastError_message_s lastError_section_s method_s url_s responseCode_d responseSize_d cache_s clientProtocol_s lastError_elapsed_d clientTime_d matchedConnections_d systemId_g vnetResourceGuid_g subnetPrefix_s macAddress_s primaryIPv4Address_s ruleName_s direction_s type_s instanceId_s healthyHostCount_d unHealthyHostCount_d requestCount_d latency_d failedRequestCount_d throughput_d priority_d conditions_protocols_s conditions_sourcePortRange_s conditions_destinationPortRange_s conditions_destinationIP_s conditions_sourceIP_s conditions_None_s trustedService_s CorrelationId identity_claim_http_schemas_microsoft_com_identity_claims_scope_s isAccessPolicyMatch_b certificateProperties_attributes_enabled_b certificatePolicyProperties_certificateProperties_subject_s certificatePolicyProperties_certificateProperties_validityInMonths_d certificatePolicyProperties_keyProperties_type_s certificatePolicyProperties_keyProperties_size_d certificatePolicyProperties_keyProperties_reuse_b certificatePolicyProperties_keyProperties_export_b certificatePolicyProperties_certificateIssuerProperties_name_s certificateEnrollmentProperties_id_s certificateEnrollmentProperties_certificateProperties_subject_s certificateEnrollmentProperties_certificateProperties_sha1_s certificateEnrollmentProperties_certificateProperties_sha256_s certificateEnrollmentProperties_certificateProperties_nbf_t certificateEnrollmentProperties_certificateProperties_exp_t certificateEnrollmentProperties_keyProperties_size_d certificateEnrollmentProperties_keyProperties_type_s certificateEnrollmentProperties_secretProperties_type_s certificateEnrollmentProperties_attributes_created_d certificateEnrollmentProperties_attributes_enabled_b certificateEnrollmentProperties_attributes_updated_d ResultDescription keyProperties_type_s keyProperties_size_d secretProperties_type_s certificateProperties_subject_s certificateProperties_sha1_s certificateProperties_sha256_s certificateProperties_nbf_t certificateProperties_exp_t Category OperationName ResultType CallerIPAddress identity_claim_http_schemas_microsoft_com_identity_claims_objectidentifier_g identity_claim_http_schemas_xmlsoap_org_ws_2005_05_identity_claims_upn_s identity_claim_appid_g id_s clientInfo_s requestUri_s httpStatusCode_d vaultProperties_s ResourceId OperationVersion ResultSignature DurationMs SubscriptionId ResourceGroup ResourceProvider Resource ResourceType Type _ResourceId
If you want specific logs according to your application. You can use <log-to-eventhub/> in apim policy in the endpoint level / api level / product level.
Please see below link to know moer about this policy.
https://github.com/MicrosoftDocs/azure-docs/blob/master/articles/api-management/api-management-log-to-eventhub-sample.md
In policy, you will get all the request and response objects from context object.
Please see the link to know more about Context variables.
https://learn.microsoft.com/en-us/azure/api-management/api-management-policy-expressions#ContextVariables
For headers, you can lookup the dictionary object context.Request.Header
Sorry for the long title. Having some issues randomly pop up (every handful of hours, but not on a regular schedule, could be anywhere from 3 hours to 8) when streaming data from Cloud PubSub into Cloud Datastore using Cloud Functions.
Source is a Node.js 6 script that receives an HTTP Post with info, writes to PubSub topic, then publishes topic to Cloud Datastore.
It is a modified version of this:
https://github.com/CiscoSE/serverless-cmx
Errors:
This first one happens sometimes with TCP Write instead of Read, but it's the same error.
ERROR: { Error: 14 UNAVAILABLE: TCP Read failed
at Object.exports.createStatusError (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/common.js:87:15)
at Object.onReceiveStatus (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:1188:28)
at InterceptingListener._callNext (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:564:42)
at InterceptingListener.onReceiveStatus (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:614:8)
at callback (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:841:24)
code: 14,
metadata: Metadata { _internal_repr: {} },
details: 'TCP Read failed' }
And:
ERROR: { Error: 13 INTERNAL: GOAWAY received
at Object.exports.createStatusError (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/common.js:87:15)
at Object.onReceiveStatus (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:1188:28)
at InterceptingListener._callNext (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:564:42)
at InterceptingListener.onReceiveStatus (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:614:8)
at callback (/user_code/node_modules/#google-cloud/datastore/node_modules/grpc/src/client_interceptors.js:841:24)
code: 13,
metadata: Metadata { _internal_repr: {} },
details: 'GOAWAY received' }
It looks like there is a similar error for other services and the workaround is just to retry.