func createEnvelope(eventType events.Envelope_EventType) *events.Envelope {
	envelope := &events.Envelope{Origin: proto.String("origin"), EventType: &eventType, Timestamp: proto.Int64(time.Now().UnixNano())}

	switch eventType {
	case events.Envelope_HttpStartStop:
		req, _ := http.NewRequest("GET", "http://www.example.com", nil)
		req.RemoteAddr = "www.example.com"
		req.Header.Add("User-Agent", "user-agent")
		uuid, _ := uuid.NewV4()
		envelope.HttpStartStop = factories.NewHttpStartStop(req, http.StatusOK, 128, events.PeerType_Client, uuid)
	case events.Envelope_ValueMetric:
		envelope.ValueMetric = factories.NewValueMetric("some-value-metric", 123, "km")
	case events.Envelope_CounterEvent:
		envelope.CounterEvent = factories.NewCounterEvent("some-counter-event", 123)
	case events.Envelope_LogMessage:
		envelope.LogMessage = factories.NewLogMessage(events.LogMessage_OUT, "some message", "appId", "source")
	case events.Envelope_ContainerMetric:
		envelope.ContainerMetric = factories.NewContainerMetric("appID", 123, 1, 5, 5)
	case events.Envelope_Error:
		envelope.Error = factories.NewError("source", 123, "message")
	default:
		panic(fmt.Sprintf("Unknown event %v\n", eventType))
	}

	return envelope
}
					Origin:    proto.String("origin"),
					EventType: events.Envelope_HttpStop.Enum(),
					HttpStop:  factories.NewHttpStop(request, 200, 567, events.PeerType_Client, uuid),
				}
				message, err := proto.Marshal(httpStop)
				Expect(err).ToNot(HaveOccurred())
				_, err = unmarshaller.UnmarshallMessage(message)
				Expect(err).ToNot(HaveOccurred())
				Eventually(func() uint64 { return fakeSender.GetCounter("dropsondeUnmarshaller.httpStopReceived") }).Should(BeEquivalentTo(1))
			})

			It("CounterEvent", func() {
				counterEvent := &events.Envelope{
					Origin:       proto.String("origin"),
					EventType:    events.Envelope_CounterEvent.Enum(),
					CounterEvent: factories.NewCounterEvent("counter", 5),
				}
				message, err := proto.Marshal(counterEvent)
				Expect(err).ToNot(HaveOccurred())
				_, err = unmarshaller.UnmarshallMessage(message)
				Expect(err).ToNot(HaveOccurred())
				Eventually(func() uint64 { return fakeSender.GetCounter("dropsondeUnmarshaller.counterEventReceived") }).Should(BeEquivalentTo(1))
			})

			It("ValueMetric", func() {
				valueMetric := &events.Envelope{
					Origin:      proto.String("origin"),
					EventType:   events.Envelope_ValueMetric.Enum(),
					ValueMetric: factories.NewValueMetric("name", 3.0, "unit"),
				}
				message, err := proto.Marshal(valueMetric)
			Expect(err).NotTo(HaveOccurred())
			appID := guid.String()

			logMessage := factories.NewLogMessage(events.LogMessage_OUT, message, appID, "APP")
			SendEventTCP(logMessage, conn)

			receivedMessageBytes := []byte{}
			Eventually(receiveChan).Should(Receive(&receivedMessageBytes))

			receivedMessage := DecodeProtoBufLogMessage(receivedMessageBytes)
			Expect(receivedMessage.GetAppId()).To(Equal(appID))
			Expect(string(receivedMessage.GetMessage())).To(Equal(message))
		})

		It("listens for dropsonde counter event on TLS port", func() {
			counterEvent := factories.NewCounterEvent("my-counter", 1)
			SendEventTCP(counterEvent, conn)

			receivedEventBytes := []byte{}
			Eventually(receiveChan).Should(Receive(&receivedEventBytes))

			receivedEvent := DecodeProtoBufCounterEvent(receivedEventBytes)
			Expect(receivedEvent.GetName()).To(Equal("my-counter"))
			Expect(receivedEvent.GetDelta()).To(Equal(uint64(1)))
		})
	})

	Context("Connecting over TCP", func() {
		BeforeEach(func() {
			ip, _ := localip.LocalIP()
			Expect(err).NotTo(HaveOccurred())