Learn about WebSockets using Swift and Vapor by building a question and answer client and server app.
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/13209594-an-introduction-to-websockets
Learn about WebSockets using Swift and Vapor by building a question and answer client and server app.
I have always been happy with raywenderlich.com articles. They are generally VERY good quality. I have learnt much from them and I am grateful they are there.
However, I am not very happy with this article. Having never used websockets before I wanted to learn about them and came here. The article is easy to understand and thatâs great. Except I canât get the example to run! Even if I download the resources and run the final product, no dice.
I have tried Xcode 11 (as specified), Xcode 12. I even tried upgrading the libraries. No luck. I can get the basic connection handshake working but cannot send messages and I have no idea why.
This is particularly frustrating as my experience with this website has up to now been excellent. If someone could check out the code and perhaps reproduce the problem that would be great.
I have no idea why its not working and normally I donât have to debug your guys code. Usually its my code thatâs buggy! Any help would be appreciated!
Hi @rleclus,
Thatâs very unfortunate to hear! Do you have any extra information to offer? What exactly is not working? Everything, or just a specific part. And is it the backend part, or the iOS app thatâs misbehaving.
If you can provide some extra details Iâm more than happy to look into it, so we can get your project working again
Thanks!
I had the same issue as well.
The error messages are as follows:
The package product âSQLiteNIOâ requires minimum platform version 13.0 for the iOS platform, but this target supports 8.0.
The package product âCryptoâ requires minimum platform version 13.0 for the iOS platform, but this target supports 8.0.
Hi there, thanks a lot for this tutorial. Everything worked fine for me except the last part with âAnswering the Questionsâ where we build in the Leaf page. After inserting the first code snipped the html page doesnât display anything except a json string. In the console I am getting this error everytime refreshing the page:
[ ERROR ] LeafError(file:"/Users/*/Library/Developer/Xcode/DerivedData/websockets-backend-âŠ/SourcePackages/checkouts/leaf-kit/Sources/LeafKit/LeafSource/LeafSources.swift", function: âsearchSources(t:on:s:)â, line: 76, column: 69, reason: LeafKit.LeafError.Reason.noTemplateExists(âquestionsâ))
At the error line there is this following code: guard !s.isEmpty else { return eL.makeFailedFuture(LeafError(.noTemplateExists(t))) }
I was only interested in the socket stuff so I am really happy that it worked so far, but maybe other people want to get Leaf to work as well, would be really helpful for them to fix that part I guess
Thanks so much,
Chrissi
Hi,
Thank you for the project, itâs really great.
In the example, the server side listen to the port 8080 and I have to use an other one.
So I would like to know if itâs possible to change the listening âportâ.
Thank you.
As a person who has designed a lot of tech education curriculum, I have to ask you, what are you actually trying to teach here?
The information that anybody would come to this page to learn is not âhow do I create a Q&A system?â If they did, the title would represent that. I came here, and Iâm sure that 99% of others came here to learn how to use Websockets. Is that in this tutorial? Yes, it is.
Now the question is, what level of understanding would a visitor need to bring to this page to extricate that information from the endless cruft? And the answer is, More than is needed to follow the tutorial.
If youâre going to teach someone a skill, start with the skill. Then, elaborate on it. If you want, before you teach them the core skill, talk about the applications that this technique has. What if Iâm trying to keep two playersâ iOS games in sync? What if Iâm trying to push out an up-to-the-minute information system for whose car is up for service in a garage? What if Iâm trying to gather the readings of 500 sensors in an IoT network, and send those on to a series of warning devices?
The reality is that about 90% of whatâs in this project would need to be stripped out to make this relevant to those use-cases.
If you donât know what an MVP is, research it, and think about it. But Iâm sure you do. This should start as an MVP, and then take it in other directions, if thatâs appropriate.
In programmer talk, this is separation of concerns. You do it every day, when you code professionally. Why not here? Separate the actual subject (the Controller), from the implementation (the Presentation layer), and the specific type of data (the Model). Establish the Controller, mock in the data, assume the interface will be handled by others who donât need to know how the sausages are made. Simple.
Some Wenderlich material is good. This is not.
Wanted to learn more about WebSockets, didnât even get out of âTesting the WebSocketâ chapter, because provided web service doesnât work anymore. Please update material.
Same here. Decided to give this a try as a learning exercise/to up skill a bit, and the web service is not available, - but worse, the project doesnât even build because some of the dependencies are out of date. I really hope thereâs an updated version out or at least in the works.
Hi! Iâm having issues while running the backend project, the error says:
Iâm using a Macbook air M1.
I had that problem, make sure youâre compiling with Rosetta
Seems to now work, Iâm able to go through all the tutorial with no issues. For the websocket server I used websocket king client extension in chrome. Iâm pretty sure piesocket extension can also work.