Skip to content

SendMessage uses wrong Accept header #7

Description

@sappenin

The IL-RFC-38 specifies that SettlementEngine messages should have an Accept and Content-Type header value of application/octet-stream. However, the current implementation of settlement-core seems to errantly be specifying an Accept header of application/json. The errant code is here.

Here's the error message produced by the settlement-xrp when trying to communicate with the Java Connector:

STDERR: 2020-02-01T20:24:52.986Z settlement-xrp Failed to settle: Error fetching payment details: account=b145eec0-be64-4bb5-b8f5-60deedc2811f xrp=0.000001 Error: socket hang up
STDERR:     at connResetException (internal/errors.js:570:14)
STDERR:     at Socket.socketOnEnd (_http_client.js:440:23)
STDERR:     at Socket.emit (events.js:215:7)
STDERR:     at endReadableNT (_stream_readable.js:1184:12)
STDERR:     at processTicksAndRejections (internal/process/task_queues.js:80:21) {
STDERR:   code: 'ECONNRESET',
STDERR:   config: {
STDERR:     url: 'http://host.testcontainers.internal:8081/accounts/b145eec0-be64-4bb5-b8f5-60deedc2811f/messages',
STDERR:     method: 'post',
STDERR:     data: <Buffer 7b 22 74 79 70 65 22 3a 22 70 61 79 6d 65 6e 74 44 65 74 61 69 6c 73 22 7d>,
STDERR:     headers: {
STDERR:       Accept: 'application/json, text/plain, */*',
STDERR:       'Content-Type': 'application/octet-stream',
STDERR:       'User-Agent': 'axios/0.19.0',
STDERR:       'Content-Length': 25
STDERR:     },
STDERR:     transformRequest: [ [Function: transformRequest] ],
STDERR:     transformResponse: [ [Function: transformResponse] ],
STDERR:     timeout: 10000,
STDERR:     adapter: [Function: httpAdapter],
STDERR:     xsrfCookieName: 'XSRF-TOKEN',
STDERR:     xsrfHeaderName: 'X-XSRF-TOKEN',
STDERR:     maxContentLength: -1,
STDERR:     validateStatus: [Function: validateStatus]
STDERR:   },
STDERR:   request: Writable {
STDERR:     _writableState: WritableState {
STDERR:       objectMode: false,
STDERR:       highWaterMark: 16384,
STDERR:       finalCalled: false,
STDERR:       needDrain: false,
STDERR:       ending: false,
STDERR:       ended: false,
STDERR:       finished: false,
STDERR:       destroyed: false,
STDERR:       decodeStrings: true,
STDERR:       defaultEncoding: 'utf8',
STDERR:       length: 0,
STDERR:       writing: false,
STDERR:       corked: 0,
STDERR:       sync: true,
STDERR:       bufferProcessing: false,
STDERR:       onwrite: [Function: bound onwrite],
STDERR:       writecb: null,
STDERR:       writelen: 0,
STDERR:       bufferedRequest: null,
STDERR:       lastBufferedRequest: null,
STDERR:       pendingcb: 0,
STDERR:       prefinished: false,
STDERR:       errorEmitted: false,
STDERR:       emitClose: true,
STDERR:       autoDestroy: false,
STDERR:       bufferedRequestCount: 0,
STDERR:       corkedRequestsFree: [Object]
STDERR:     },
STDERR:     writable: true,
STDERR:     _events: [Object: null prototype] {
STDERR:       response: [Function: handleResponse],
STDERR:       error: [Function: handleRequestError]
STDERR:     },
STDERR:     _eventsCount: 2,
STDERR:     _maxListeners: undefined,
STDERR:     _options: {
STDERR:       protocol: 'http:',
STDERR:       maxRedirects: 21,
STDERR:       maxBodyLength: 10485760,
STDERR:       path: '/accounts/b145eec0-be64-4bb5-b8f5-60deedc2811f/messages',
STDERR:       method: 'POST',
STDERR:       headers: [Object],
STDERR:       agent: undefined,
STDERR:       auth: undefined,
STDERR:       hostname: 'host.testcontainers.internal',
STDERR:       port: '8081',
STDERR:       nativeProtocols: [Object],
STDERR:       pathname: '/accounts/b145eec0-be64-4bb5-b8f5-60deedc2811f/messages'
STDERR:     },
STDERR:     _redirectCount: 0,
STDERR:     _redirects: [],
STDERR:     _requestBodyLength: 25,
STDERR:     _requestBodyBuffers: [ [Object] ],
STDERR:     _onNativeResponse: [Function],
STDERR:     _currentRequest: ClientRequest {
STDERR:       _events: [Object: null prototype],
STDERR:       _eventsCount: 6,
STDERR:       _maxListeners: undefined,
STDERR:       outputData: [],
STDERR:       outputSize: 0,
STDERR:       writable: true,
STDERR:       _last: true,
STDERR:       chunkedEncoding: false,
STDERR:       shouldKeepAlive: false,
STDERR:       useChunkedEncodingByDefault: true,
STDERR:       sendDate: false,
STDERR:       _removedConnection: false,
STDERR:       _removedContLen: false,
STDERR:       _removedTE: false,
STDERR:       _contentLength: null,
STDERR:       _hasBody: true,
STDERR:       _trailer: '',
STDERR:       finished: true,
STDERR:       _headerSent: true,
STDERR:       socket: [Socket],
STDERR:       connection: [Socket],
STDERR:       _header: 'POST /accounts/b145eec0-be64-4bb5-b8f5-60deedc2811f/messages HTTP/1.1\r\n' +
STDERR:         'Accept: application/json, text/plain, */*\r\n' +
STDERR:         'Content-Type: application/octet-stream\r\n' +
STDERR:         'User-Agent: axios/0.19.0\r\n' +
STDERR:         'Content-Length: 25\r\n' +
STDERR:         'Host: host.testcontainers.internal:8081\r\n' +
STDERR:         'Connection: close\r\n' +
STDERR:         '\r\n',
STDERR:       _onPendingData: [Function: noopPendingOutput],
STDERR:       agent: [Agent],
STDERR:       socketPath: undefined,
STDERR:       method: 'POST',
STDERR:       path: '/accounts/b145eec0-be64-4bb5-b8f5-60deedc2811f/messages',
STDERR:       _ended: false,
STDERR:       res: null,
STDERR:       aborted: false,
STDERR:       timeoutCb: null,
STDERR:       upgradeOrConnect: false,
STDERR:       parser: null,
STDERR:       maxHeadersCount: null,
STDERR:       _redirectable: [Circular],
STDERR:       [Symbol(kNeedDrain)]: false,
STDERR:       [Symbol(isCorked)]: false,
STDERR:       [Symbol(kOutHeaders)]: [Object: null prototype]
STDERR:     },
STDERR:     _currentUrl: 'http://host.testcontainers.internal:8081/accounts/b145eec0-be64-4bb5-b8f5-60deedc2811f/messages'
STDERR:   },
STDERR:   response: undefined,
STDERR:   isAxiosError: true,
STDERR:   toJSON: [Function]
STDERR: }
STDERR: 2020-02-01T20:24:53.003Z settlement-core Settlement completed: leftover=0.0000011 settled=0 amountToSettle=0.0000011 account=b145eec0-be64-4bb5-b8f5-60deedc2811f

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions