diff --git a/packages/binding-opcua/src/codec.ts b/packages/binding-opcua/src/codec.ts index 77add05b2..51320ee9b 100644 --- a/packages/binding-opcua/src/codec.ts +++ b/packages/binding-opcua/src/codec.ts @@ -258,7 +258,7 @@ export const theOpcuaJSONCodec = new OpcuaJSONCodec(); export class OpcuaBinaryCodec implements ContentCodec { getMediaType(): string { - return "application/opcua+octet-stream"; // see Ege + return "application/opcua+octet-stream"; } bytesToValue(bytes: Buffer, schema: DataSchema, parameters?: { [key: string]: string }): DataValueJSON { diff --git a/packages/binding-opcua/src/opcua-protocol-client.ts b/packages/binding-opcua/src/opcua-protocol-client.ts index 37b94e5ee..07e8ef1c1 100644 --- a/packages/binding-opcua/src/opcua-protocol-client.ts +++ b/packages/binding-opcua/src/opcua-protocol-client.ts @@ -302,6 +302,13 @@ export class OPCUAProtocolClient implements ProtocolClient { return this._resolveNodeId2(form, fNodeId as NodeIdLike | NodeByBrowsePath); } + // node-opcua handles the contentType internally and no further *external* processing should be done + private vanishContentType(form: OPCUAForm) { + if (!(form.contentType === "application/opcua+json" || form.contentType === "application/opcua+octet-stream")) { + form.contentType = undefined; + } + } + public async readResource(form: OPCUAForm): Promise { debug(`readResource: reading ${form}`); @@ -314,6 +321,7 @@ export class OPCUAProtocolClient implements ProtocolClient { return this._dataValueToContent(form, dataValue); }); debug(`readResource: contentType ${content.type}`); + this.vanishContentType(form); return content; }