Skip to content

Unable to get the Response message after calling Send method #100

@savurirasan

Description

@savurirasan

"I'm writing the client code. The server successfully receives the request and sends the response, but the client isn't able to read the response—it times out. However, when I test with raw TCP code instead of using the IsoConnection, the response is received correctly.

t.Run("sends messages to server and receives responses", func(t *testing.T) {
c, err := connection.New("13.126.17.109:8970", connection.Spec, readMessageLength, writeMessageLength)
require.NoError(t, err)
err = c.Connect()
require.NoError(t, err)

	// network management message
	message := iso8583.NewMessage(connection.Spec)
	err = message.Marshal(connection.NewNetworkManagementRequest())

	require.NoError(t, err)

	// we can send iso message to the server
	response, err := c.Send(message)
	require.NoError(t, err)
	time.Sleep(1 * time.Second)

	mti, err := response.GetMTI()
	t.Log(mti)
	require.NoError(t, err)
	require.Equal(t, "0810", mti)

	require.NoError(t, c.Close())
})

func readMessageLength(r io.Reader) (int, error) {
header := network.NewBinary2BytesHeader()
n, err := header.ReadFrom(r)
if err != nil {
return n, err
}

return header.Length(), nil

}

func writeMessageLength(w io.Writer, length int) (int, error) {
header := network.NewBinary2BytesHeader()
header.SetLength(length)

n, err := header.WriteTo(w)
if err != nil {
	return n, fmt.Errorf("writing message header: %w", err)
}

return n, nil

}

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