function encodeJoinGroupRequest (clientId, correlationId, groupId, memberId, sessionTimeout, groupProtocols) {
  var request = encodeRequestHeader(clientId, correlationId, REQUEST_TYPE.joinGroup);
  request
    .Int16BE(groupId.length)
    .string(groupId)
    .Int32BE(sessionTimeout)
    .Int16BE(memberId.length)
    .string(memberId)
    .Int16BE(GROUPS_PROTOCOL_TYPE.length)
    .string(GROUPS_PROTOCOL_TYPE)
    .Int32BE(groupProtocols.length);

  groupProtocols.forEach(encodeGroupProtocol.bind(request));

  return encodeRequestWithLength(request.make());
}