Skip to content

how to set WriteTimeout in client #218

@en-vee

Description

@en-vee

Hi,
My gy client application goroutines are getting blocked in this mutex.Lock call
And ultimately, running out of memory.
How can I set the WriteTimeout when acting as a Diameter Gy client and performing a WriteToWithRetry call

func (w *response) Write(b []byte) (int, error) {
	w.mu.Lock()
	defer w.mu.Unlock()
	if w.conn.server.WriteTimeout > 0 {
		w.conn.rwc.SetWriteDeadline(time.Now().Add(w.conn.server.WriteTimeout))
	}
	msc, isMulti := w.conn.rwc.(MultistreamConn) // Note - SetWriteDeadline is not currently supported for SCTP
	if isMulti {                                 // don't use buffered writer for muti-streamming writes it'll mix up streams
		return msc.Write(b)
	}
	n, err := w.conn.buf.Writer.Write(b)
	if err != nil {
		return 0, err
	}
	if err = w.conn.buf.Writer.Flush(); err != nil {
		return 0, err
	}
	return n, nil
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions