func (communication *HTTP) StopCommunication() common.SyncServiceError {
	communication.started = false
	communication.httpPollStopChannel <- 1
	if communication.httpPollTimer != nil {
		communication.httpPollTimer.Stop()
	}
	communication.requestWrapper.cancel()
	return nil
}
StopCommunication stops communications
package communications
import (
	"bytes"
	"crypto/tls"
	"crypto/x509"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"os"
	"strconv"
	"strings"
	"time"
	"github.com/open-horizon/edge-sync-service/common"
	"github.com/open-horizon/edge-sync-service/core/dataURI"
	"github.com/open-horizon/edge-sync-service/core/dataVerifier"
	"github.com/open-horizon/edge-sync-service/core/security"
	"github.com/open-horizon/edge-utilities/logger"
	"github.com/open-horizon/edge-utilities/logger/log"
	"github.com/open-horizon/edge-utilities/logger/trace"
)
const registerURL = "/spi/v1/register/"
const registerNewURL = "/spi/v1/register-new/"
const unregisterURL = "/spi/v1/unregister/"
const pingURL = "/spi/v1/ping/"
const objectRequestURL = "/spi/v1/objects/"
var unauthorizedBytes = []byte("Unauthorized")
type HTTP struct {
	httpClient          http.Client
	started             bool
	httpPollTimer       *time.Timer
	httpPollStopChannel chan int
	requestWrapper      *httpRequestWrapper
}
type updateMessage struct {
	Type     string
	MetaData common.MetaData
}
type feedbackMessage struct {
	Code          int
	RetryInterval int32
	Reason        string
}
func (communication *HTTP) StartCommunication() common.SyncServiceError {
	if common.Configuration.NodeType == common.CSS {
		http.Handle(registerURL, http.StripPrefix(registerURL, http.HandlerFunc(communication.handleRegister)))
		http.Handle(registerNewURL, http.StripPrefix(registerNewURL, http.HandlerFunc(communication.handleRegisterNew)))
		http.Handle(unregisterURL, http.StripPrefix(unregisterURL, http.HandlerFunc(communication.handleUnregister)))
		http.Handle(pingURL, http.StripPrefix(pingURL, http.HandlerFunc(communication.handlePing)))
		http.Handle(objectRequestURL, http.StripPrefix(objectRequestURL, http.HandlerFunc(communication.handleObjects)))
	} else {
		communication.httpClient = http.Client{
			Transport: &http.Transport{},
			Timeout:   time.Second * time.Duration(common.Configuration.HTTPESSClientTimeout),
		}
		if common.Configuration.HTTPCSSUseSSL && len(common.Configuration.HTTPCSSCACertificate) > 0 {
			var caFile string
			if strings.HasPrefix(common.Configuration.HTTPCSSCACertificate, "/") {
				caFile = common.Configuration.HTTPCSSCACertificate
			} else {
				caFile = common.Configuration.PersistenceRootPath + common.Configuration.HTTPCSSCACertificate
			}
			certificate, err := ioutil.ReadFile(caFile)
			if err != nil {
				if _, ok := err.(*os.PathError); ok {
					certificate = []byte(common.Configuration.HTTPCSSCACertificate)
				} else {
					return err
				}
			}
			caCertPool := x509.NewCertPool()
			caCertPool.AppendCertsFromPEM(certificate)
			tlsConfig := &tls.Config{RootCAs: caCertPool}
			communication.httpClient.Transport = &http.Transport{TLSClientConfig: tlsConfig}
		}
		communication.httpPollStopChannel = make(chan int, 1)
		communication.requestWrapper = newHTTPRequestWrapper(communication.httpClient)
	}
	communication.started = true
	return nil
}
func (communication *HTTP) startPolling() {
	configuredInterval := int(common.Configuration.HTTPPollingInterval) * 1000
	go func() {
		common.GoRoutineStarted()
		keepRunning := true
		initialPoll := true
		interval := 1000
		communication.httpPollTimer = time.NewTimer(time.Millisecond * time.Duration(interval))
		for keepRunning {
			select {
			case <-communication.httpPollTimer.C:
				update := false
				for communication.Poll() {
					update = true
				}
				if initialPoll || update {
					interval = configuredInterval / 10
					update = false
					initialPoll = false
				} else if interval < configuredInterval {
					interval += configuredInterval / 10
				}
				communication.httpPollTimer = time.NewTimer(time.Millisecond * time.Duration(interval))
			case <-communication.httpPollStopChannel:
				keepRunning = false
			}
		}
		communication.httpPollTimer = nil
		common.GoRoutineEnded()
	}()
}