587 Commits

Author SHA1 Message Date
mochi-co
5b7f94bde4 Update server version v2.7.9 2025-03-01 13:52:49 +00:00
thedevop
b4332150f8 Improve message expiry (#460) 2025-03-01 13:50:37 +00:00
mochi-co
de82bddb83 Update server version v2.7.8 2025-02-25 20:16:39 +00:00
mochi-co
ce88723041 update server version v2.6.7 2025-01-30 18:37:55 +00:00
dagehuifei
d3b62035f9 feat: Add TLS Cert File flag (#434)
Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2025-01-30 18:25:18 +00:00
dependabot[bot]
9441e92595 Bump golang.org/x/net from 0.23.0 to 0.33.0 (#450)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.23.0 to 0.33.0.
- [Commits](https://github.com/golang/net/compare/v0.23.0...v0.33.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2025-01-30 18:05:35 +00:00
thedevop
bfaf78332b Suppress OnPublish CodeSuccessIgnore error log (#438)
* OnPublish CodeSuccessIgnore, use debug instead of error log

* Suppress OnPublish CodeSuccessIgnore error log

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2025-01-30 18:02:25 +00:00
thedevop
043906876e Add cl.IsTakenOver and switch cl.isTakenOver to atomic.Bool (#446)
* OnPublish CodeSuccessIgnore, use debug instead of error log

* Suppress OnPublish CodeSuccessIgnore error log

* Add cl.IsTakenOver and switch to use atomic.Bool

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2025-01-30 17:58:03 +00:00
dependabot[bot]
dcb814cedf Bump github.com/golang/glog from 1.0.0 to 1.2.4 (#449)
Bumps [github.com/golang/glog](https://github.com/golang/glog) from 1.0.0 to 1.2.4.
- [Release notes](https://github.com/golang/glog/releases)
- [Commits](https://github.com/golang/glog/compare/v1.0.0...v1.2.4)

---
updated-dependencies:
- dependency-name: github.com/golang/glog
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2025-01-30 17:54:44 +00:00
mochi-co
8f52b891d5 Update server version v2.6.6 2024-10-23 21:06:28 +01:00
s9-hfe
47536b77f2 Fix QoS 1 message delivery after server restart (#427)
Resolved an issue where persisted QoS 1 messages were not correctly loaded
into the appropriate client instance during server startup.
2024-10-23 21:02:45 +01:00
mochi-co
830de149dc Update server version v2.6.5 2024-07-30 20:24:12 +01:00
Simon
34f9370f8c use cl.ID instead of pk.Connect.ClientIdentifier when looking for existing clients in inheritClientSession (#417)
* use cl.id instead of pk.Connect.ClientIdentifier which is client-supplied, when looking for existing clients in inheritClientSession

* look for assigned client id explicitly

* simpler implementation using just cl.ID

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-07-30 19:09:16 +01:00
Cendeal
dc272d2c36 add description for MaximumClientWritesPending(#410) (#411) 2024-07-30 19:02:32 +01:00
mochi-co
82c96fa4e3 Update server version v2.6.4 2024-05-19 19:15:53 +01:00
Jens Alfke
01f81ebeee Added omitempty to storage structs (#401)
This significantly cuts down the size of the marshaled JSON.

I've left it out on fields that, in my experience, never have the
default value.
2024-05-19 19:12:57 +01:00
Jens Alfke
cc3f827fc1 Added client.StopTime(), to expose disconnected (#400)
* Added client.StopTime() to expose `disconnected`

* Added a test of Client.StopTime()

I added a check to TestClientStop(), both before and after stopping.

I also noticed a race condition in the test (comparing a time against
time.Now) and fixed it to allow a one-second discrepancy.
2024-05-19 19:11:24 +01:00
mochi-co
5966c7fe0d Update server version v2.6.3 2024-04-30 10:04:01 +01:00
werben
b26e03a433 Bypassing asdine/storm and directly using bbolt. (#392)
* Fix the bug where inline subscribers do not receive messages after all non-inline clients unsubscribe.

* Bypassing asdine/storm and directly using bbolt.

* Fixed erroneous removal of FileContributor.

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-04-30 10:03:22 +01:00
dependabot[bot]
6fc4027a78 Bump golang.org/x/net from 0.17.0 to 0.23.0 (#388)
Bumps [golang.org/x/net](https://github.com/golang/net) from 0.17.0 to 0.23.0.
- [Commits](https://github.com/golang/net/compare/v0.17.0...v0.23.0)

---
updated-dependencies:
- dependency-name: golang.org/x/net
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-04-30 09:21:53 +01:00
Derek Duncan
b9d2dfb824 Add logging level file config (#396)
* add logging level to file config

* remove last zerolog references

* add levelvar to unit test

---------

Co-authored-by: Derek Duncan <derekduncan@gmail.com>
Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-04-30 09:08:45 +01:00
thedevop
d5d9b02b28 Update README example to reflect new listeners API (#389)
* Update README example to reflect new listeners API

* Update README example to reflect new listeners API

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-04-30 09:03:34 +01:00
Derek Duncan
64ea905c41 add 0x04 Reason Code functionality (#395)
* add 0x04 Reason Code functionality

* fix tpackets test

* simplify logic

---------

Co-authored-by: Derek Duncan <derekduncan@gmail.com>
2024-04-30 08:57:16 +01:00
mochi-co
57997ef0c1 update server version v2.6.2 2024-04-16 17:12:03 +01:00
werben
21491d9b4e Fix the bug where inline subscribers do not receive messages after all non-inline clients unsubscribe. (#386)
Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-04-16 17:08:06 +01:00
thedevop
cb217cd3b3 Ability to limit maximum number of clients (#379)
* Ability to limit maximum number of clients

* Use ErrServerBusy instead of ErrQuotaExceeded

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-04-16 17:05:28 +01:00
mochi-co
6b3b30e412 Update server version v2.6.1 2024-04-01 18:00:19 +01:00
werben
e2cb688869 Replace badgerhold with directly using BadgerDB v4 (#376)
* Replace badgerhold with directly using BadgerDB v4.

* Optimize code and test cases.

* Optimize code.

* Set the default size of the log file to 100 MB.

* Resolve merge conflicts.
2024-04-01 17:51:02 +01:00
werben
d048e4bef7 Add a persistence hook based on cockroachdb/pebble. (#378)
* Implementing Pebble as a persistence database hook.

* Fixed failing test cases.

* Add Pebble DB configuration for file-based configuration, optimize part of the code.

* Resolve test failure issues and perform code optimization.

* Optimized the test cases.
2024-03-28 10:02:18 +00:00
werben
47162a3770 Translate README.md into Chinese version. (#373) 2024-03-18 11:11:31 +00:00
mochi-co
074e1b06ae fix docker image v2.6.0 2024-03-18 04:10:16 +00:00
JB
26418c6fd8 Implement File based configuration (#351)
* Implement file-based configuration

* Implement file-based configuration

* Replace DefaultServerCapabilities with NewDefaultServerCapabilities() to avoid data race (#360)

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>

* Only pass a copy of system.Info to hooks (#365)

* Only pass a copy of system.Info to hooks

* Rename Itoa to Int64toa

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>

* Allow configurable max stored qos > 0 messages (#359)

* Allow configurable max stored qos > 0 messages

* Only rollback Inflight if QoS > 0

* Only rollback Inflight if QoS > 0

* Minor refactor

* Update server version

* Implement file-based configuration

* Implement file-based configuration

* update configs with maximum_inflight value

* update docker configuration

* fix tests

---------

Co-authored-by: mochi-co <moumochi@icloud.com>
Co-authored-by: thedevop <60499013+thedevop@users.noreply.github.com>
2024-03-18 03:28:12 +00:00
werben
26720c2f6e Add BadgerDB garbage collection. (#371)
* For issues #370, #369, and #363, add BadgerDB garbage collection.

* Add default configuration for defaultGcInterval.

* Solve DATA RACE.

* Place Badger's configuration in main.go for users to adjust as needed.

* Add TestGcLoop() for coverage.

* Modify GcInterval to shorten test time.

* Add the GcDiscardRatio option for the Badger hook, and include more detailed comments in the example.

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-03-18 00:16:55 +00:00
dependabot[bot]
d30592b95b Bump google.golang.org/protobuf from 1.28.1 to 1.33.0 (#372)
Bumps google.golang.org/protobuf from 1.28.1 to 1.33.0.

---
updated-dependencies:
- dependency-name: google.golang.org/protobuf
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-03-17 22:18:03 +00:00
mochi-co
40e9cdb383 Update server version v2.4.6 2024-02-05 21:37:41 +00:00
thedevop
e9f72154b6 Allow configurable max stored qos > 0 messages (#359)
* Allow configurable max stored qos > 0 messages

* Only rollback Inflight if QoS > 0

* Only rollback Inflight if QoS > 0

* Minor refactor
2024-02-05 21:24:34 +00:00
thedevop
69412dd23c Only pass a copy of system.Info to hooks (#365)
* Only pass a copy of system.Info to hooks

* Rename Itoa to Int64toa

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-02-04 13:36:50 +00:00
thedevop
686c35ac0c Replace DefaultServerCapabilities with NewDefaultServerCapabilities() to avoid data race (#360)
Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-02-04 09:23:26 +00:00
mochi-co
65c78534dc Update server version v2.4.5 2024-01-11 22:56:55 +00:00
thedevop
83db7fff56 Buffer optimizations (#355)
* Avoid creating buffer if pkt larger than ClientNetWriteBufferSize

* Use mempool for Properties Encode

* Use the more efficient Write instead of Write for Buffer to Buffer write

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2024-01-10 08:15:06 +00:00
werben
10a02ab3c7 Fix #349, MQTT v3 unsuback does not require Reason Code. (#353) 2024-01-10 07:55:41 +00:00
mochi-co
5058333f36 Update server version v2.4.4 2023-12-22 00:40:56 +00:00
werben
b2ab984949 Move cl.WriteLoop() to attachClient() and call cl.Stop() in loadClients() to update client.State. (#344)
* Moving go cl.WriteLoop() out of NewClient() and placing it in server.attachClient().

* Call cl.Stop() to cancel the context, update cl.State with information such as disconnected time, and set the stopCause.

* update README-CN.md

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2023-12-22 00:34:29 +00:00
Aaron France
5523d15a9b feat: return tcp.Address from listener, if exists (#336)
* This is the more accurate and correct address of the listener
* Useful if you want to listen on port 0 to dynamically create
listeners (think of unit/integration tests)

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2023-12-21 23:59:51 +00:00
thedevop
c6c7c296f6 Packet encoding optimization (#343)
* Dynamically allocate buffer for writes if needed

* Remove unused net.Buffer

* Return bytes written to buffer instead of conn

* Dynamic write buffer

* Reduce double write of pk.Payload

* Use memory pool for packet encode

* Pool doesn't guarantee value between Put and Get

* Add benchmark for bufpool

* Fix issue #346

* Change default pool not to have size cap

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2023-12-21 23:23:35 +00:00
thedevop
4c682384c5 Fix data race issue with write buffer (#347) 2023-12-21 23:13:36 +00:00
werben
624dde0986 Handle expired clients in server.loadClients(). (#341)
* Handle expired clients in server.loadClients().

* No need to call s.Clients.Delete().

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
v2.4.3
2023-12-12 23:45:56 +00:00
thedevop
dc4eecdfb7 Dynamically allocate write buffer if needed. (ready for merge) (#324)
* Dynamically allocate buffer for writes if needed

* Remove unused net.Buffer

* Return bytes written to buffer instead of conn

* Dynamic write buffer

---------

Co-authored-by: JB <28275108+mochi-co@users.noreply.github.com>
2023-12-12 23:43:50 +00:00
Naohiro Heya
e8f151bf1f Add a Japanese version of README.md (#338)
* Add a Japanese version of README.md

* add jp link
2023-12-03 10:04:04 +00:00
werben
4983b6b977 Add a demonstration in examples/hooks on how to subscribe to a topic and publish messages directly within the hook. (#333) 2023-11-24 11:25:21 +00:00